Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.GetPersonAvailPercentage ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> create function "pears"."GetPersonAvailPercentage"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "sid" char(20),in "frdate" date,in "todate" date ) returns double begin declare "rv" double; declare "bonly" smallint; declare "cavail" char(1); declare "ndays" double; declare "navail" double; set "rv" = 0; if "frdate" is null then return null end if; if "todate" is null then set "todate" = "dateadd"("day",30,"frdate") end if; if "frdate" > "todate" then return 100 end if; set "ndays" = 0; set "navail" = 0; select first "onlymatchifknownavailable" into "bonly" from "person" where "personid" = "sid"; set "bonly" = "isnull"("bonly",0); while "frdate" <= "todate" loop set "ndays" = "ndays"+1; select first "getpersonavailstate"("sid","frdate") into "cavail"; if "cavail" = 'A' or("cavail" is null and "bonly" = 0) then set "navail" = "navail"+1 end if; set "frdate" = "dateadd"("day",1,"frdate") end loop; return("navail"/"ndays")*100 end </code> database/functions/pears_getpersonavailpercentage.txt Last modified: 2026/08/07 19:24by 127.0.0.1