pears.NotificationsExist

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

CREATE FUNCTION "pears"."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",'') = any(SELECT "DivisionID" FROM "DivisionsAllowed")
      AND "NotificationType" LIKE "pNotificationType" AND "RecipientType" LIKE "pRecipientType"
      AND("isnull"("ownerid","userstaffid") = "userstaffid")
      AND((NOT EXISTS(SELECT * FROM "NotificationDepartment" AS "d" WHERE "d"."NotificationTemplateid" = "NotificationTemplate"."NotificationTemplateid"))
      OR((NOT EXISTS(SELECT * FROM "NotificationDepartment" AS "d" WHERE "d"."NotificationTemplateid" = "NotificationTemplate"."NotificationTemplateid"))
      OR(EXISTS(SELECT * FROM "NotificationDepartment" AS "d" KEY JOIN "department" AS "dd"
        WHERE "d"."NotificationTemplateid" = "NotificationTemplate"."NotificationTemplateid" AND "dd"."departmentid" LIKE "pdeptid"
        AND "isnull"("dd"."DivisionID",'') = any(SELECT "DivisionID" FROM "DivisionsAllowed")))))) THEN
    RETURN 1
  ELSE RETURN 0
  END IF
END
  • database/functions/pears_notificationsexist.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1