pears.NotificationsExist
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NotificationsExist" IS {CREATE FUNCTION NotificationsExist /* Application Maintained Function / Procedure - DO NOT EDIT*/ (IN pTemplateid CHAR(50),IN pDeptid CHAR(2), IN pNotificationType CHAR(20), IN pRecipientType CHAR(20) ) RETURNS tinyint BEGIN IF EXISTS(SELECT * FROM NotificationTemplate WHERE isnull(Defunct,0)=0 AND NotificationType=pTemplateID AND isnull(divisionid,'') IN (SELECT DivisionID FROM DivisionsAllowed) AND NotificationType LIKE pNotificationType AND RecipientType LIKE pRecipientType AND (isnull(ownerid , userstaffid) = userstaffid) AND ((NOT EXISTS(SELECT * FROM NotificationDepartment d WHERE d.NotificationTemplateid = NotificationTemplate.NotificationTemplateid)) OR ((NOT EXISTS(SELECT * FROM NotificationDepartment d WHERE d.NotificationTemplateid = NotificationTemplate.NotificationTemplateid)) OR (EXISTS(SELECT * FROM NotificationDepartment d KEY JOIN department dd WHERE d.NotificationTemplateid = NotificationTemplate.NotificationTemplateid AND dd.departmentid LIKE pdeptid AND isnull(dd.DivisionID,'') IN (SELECT DivisionID FROM DivisionsAllowed))))) ) THEN RETURN 1 ELSE RETURN 0 END IF END }