====== pears.GetWorkPatternWeeklyHours ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."GetWorkPatternWeeklyHours"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "placid" char(20),in "pstartdate" date,in "penddate" date ) returns double begin declare "Absense" integer; declare "Hours" double; declare "Days" integer; declare "WeekHours" double; select(select "count"("state") from "TempShift" where "shiftdate" between "pStartDate" and "pEndDate" and "tempshift"."state" in( 'H','U' ) and "tempshift"."personid" = "employment"."personid") as "Absense", "Placement"."WorkNormalHours" as "Hours", ("isnull"("Placement"."WorkMonday",0) +"isnull"("Placement"."WorkTuesday",0) +"isnull"("Placement"."WorkWednesday",0) +"isnull"("Placement"."WorkThursday",0) +"isnull"("Placement"."WorkFriday",0) +"isnull"("Placement"."WorkSaturday",0) +"isnull"("Placement"."WorkSunday",0))-"Absense" as "Days", (if "Days" > 0 then "Days"*"Hours" else 0 endif) as "WeekHours" into "Absense","Hours","Days","WeekHours" from "placement" key join "employment" where "placementid" = "placid"; return "isnull"("weekhours",0) end