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