CREATE PROCEDURE PreTest_37_UDFClassifiedAsSensitiveIsInconsistentInSalesOrPurchaseAndInventoryTransfer() LANGUAGE SQLSCRIPT 
				AS 
			BEGIN
				SELECT * FROM OPFS T1
				WHERE T1."OrigType" = 'U' AND T1."TableName" IN ('ODOC', 'DOC1') AND T1."Category" IN ('R', 'A')  AND T1."Type" = 'S'
				AND NOT EXISTS (SELECT * FROM OPFS T2 WHERE T2."OrigType" = T1."OrigType" AND T2."TableName" = T1."TableName" AND T2."FieldName" = T1."FieldName" AND T2."Type" = 'S' AND T2."Category" <> T1."Category" AND T2."Category" IN ('R', 'A'))
				UNION all
				SELECT * FROM OPFS T1
				WHERE T1."OrigType" = 'U' AND T1."TableName" IN ('ODOC', 'DOC1') AND T1."Category" IN ('P', 'B') AND T1."Type" = 'S'
				AND NOT EXISTS (SELECT * FROM OPFS T2 WHERE T2."OrigType" = T1."OrigType" AND T2."TableName" = T1."TableName" AND T2."FieldName" = T1."FieldName" AND T2."Type" = 'S' AND T2."Category" <> T1."Category" AND T2."Category" IN ('P', 'B') );
			END;







