====== pears.MasterRosterStartDate ======
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"."MasterRosterStartDate" IS
{create function MasterRosterStartDate
/* Application Maintained Function / Procedure - DO NOT EDIT*/
( in MRID char(20),in VacID char(20) )
returns char(20)
begin
declare MaxDays integer;
declare SDate date;
if isnull(MRID,'') = '' then
select Max(daysincycle) into MaxDays from Masterroster where VacancyID = VacID;
select Min(startdate) into SDate from Masterroster where VacancyID = VacID and daysincycle = MaxDays
else select daysincycle,startdate into MaxDays,SDate from Masterroster where MasterRosterID = MRID
end if;
if SDate <= current date then
while current date not between Sdate and Sdate+MaxDays loop
set SDate = SDate+MaxDays
end loop
end if;
return dateFormat(SDate,'yyyy-mm-dd')
end
}