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

	SELECT	@CNT = COUNT(*)
	FROM	ITEM
	WHERE	STATUS = 10

	IF @CNT > 0
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'Items with Status "UNDER_TOP" are detected.'
	END
	ELSE
	BEGIN
		SET @STATUS = 0
		SET @MESSAGE = ''
	END
	
	SELECT @STATUS, @MESSAGE
END

