====== 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 }