====== pears.ComplianceSummary ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."ComplianceSummary"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "pPersonID" char(20) ) returns long varchar begin declare "errMsg" long varchar; declare "warnMsg" long varchar; declare "act" double; declare "poss" double; declare "xScore" char(20); set "act" = 0; set "poss" = 0; for "PFOR" as "PCUR" no scroll cursor for select "Description","Status","Info","AchievedScore","Score" from "ComplianceTable"("pPersonID") 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; set "act" = "act"+"isnull"("AchievedScore",0.0); set "poss" = "poss"+"isnull"("Score",0.0) end for; if "warnMsg" is not null then set "warnMsg" = "string"('Warning: ',"warnMsg") end if; if "poss" <= 0 then set "xScore" = '' else set "xScore" = "trim"("str"(("act"/"poss")*100.0))+'% ' end if; return "string"("xScore","errMsg","warnMsg") end