====== pears.PlacementDayHours ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."PlacementDayHours" IS {create function PlacementDayHours /* Application Maintained Function / Procedure - DO NOT EDIT*/ (in bProcess tinyint,in placid char(20),in pdate date,in startdate date,in enddate date) returns char(10) begin declare bcanc tinyint; declare scancid char(10); declare nhrs real; declare d smallint; declare bdayticked tinyint; if isnull(bProcess,0) = 0 then return '' end if; if pdate < startdate then return '' end if; if pdate > enddate then return '' end if; select first v.WorkCancelled,isnull(r.shortcode,v.TempShiftCancelReasonID),v.WorkHours into bcanc,scancid, nhrs from PlacementDayVariation as v key left outer join tempshiftcancelreason as r where v.placementid = placid and v.VariationDate = pdate; if bcanc = 1 then return isnull(scancid,'C') end if; if nhrs is not null then return nhrs end if; set d=dow(pdate)-1; select(case d when 0 then worksunday when 1 then workmonday when 2 then worktuesday when 3 then workwednesday when 4 then workthursday when 5 then workfriday when 6 then worksaturday end), worknormalhours into bdayticked,nhrs from placement where placementid = placid; if bdayticked = 1 then return nhrs end if; return '' end }