--EXEC MIG_VALIDATE_SEC_RULES_OBJECTS_Sp '', ''
CREATE OR ALTER PROCEDURE MIG_VALIDATE_SEC_RULES_OBJECTS_Sp
(
	@STATUS INT = 0 OUT,
	@MESSAGE NVARCHAR(999) = NULL OUT
)
AS 
BEGIN
	DECLARE @CNT INT

	SET @STATUS = 0
	SET @MESSAGE = ''

	SELECT	@CNT = COUNT(*)
	FROM	SEC_RULES
	LEFT JOIN
	(
		SELECT	'ITEM'		AS 'OBJ_ID',	''				AS 'LINK_ID'		--pdpdm100
		UNION
		SELECT	'DOC'		AS 'OBJ_ID',	''				AS 'LINK_ID'		--pdpdm200
		UNION
		SELECT	'FOLDER'	AS 'OBJ_ID',	''				AS 'LINK_ID'		--pdpdm300
	) T 
	 ON T.OBJ_ID = SEC_RULES.OBJ_ID
	AND T.LINK_ID = SEC_RULES.LINK_ID
	WHERE T.OBJ_ID IS NULL
	
	IF @CNT > 0
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'Security Rules found that are not supported in target application.'
	END
	ELSE
	
	SELECT @STATUS, @MESSAGE
END

