pears.ComplianceValid

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

Original SQL

CREATE FUNCTION "pears"."ComplianceValid"( 
  /* Application Maintained Function / Procedure - DO NOT EDIT*/
  IN "pPersonID" CHAR(20),IN "pComplianceDomainID" CHAR(20),IN "AtDate" DATE,IN "pClientCode" CHAR(12) DEFAULT NULL ) 
RETURNS long VARCHAR
BEGIN
  DECLARE "errMsg" long VARCHAR;
  DECLARE "warnMsg" long VARCHAR;
  FOR "PFOR" AS "PCUR" no scroll cursor FOR
    SELECT "Description","Status","Info"
      FROM "ComplianceTable"("pPersonID","pComplianceDomainID","AtDate","pClientCode") FOR READ ONLY do
    CASE "status"
    WHEN 1 THEN SET "errMsg" = "string"("errMsg","Description",' ',"Info",'. ')
    WHEN 2 THEN SET "warnMsg" = "string"("warnMsg","Description",' ',"Info",'. ')
    END CASE
  END FOR;
  IF "warnMsg" IS NOT NULL THEN
    SET "warnMsg" = "string"('Warning: ',"warnMsg")
  END IF;
  IF "errMsg" IS NOT NULL THEN
    RETURN "string"('P',"pPersonID",'>>COMPLIANCE',"char"(9),"errMsg","warnMsg")
  ELSE IF "warnMsg" IS NOT NULL THEN
      RETURN "string"('^P',"pPersonID",'>>COMPLIANCE',"char"(9),"warnMsg")
    END IF
  END IF
END