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