====== pears.GetCascadeTime ======
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"."GetCascadeTime" IS
{create function GetCascadeTime
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in compid char(20),in vacid char(20),in entrytime timestamp,in shifttime timestamp,in casctime timestamp,in requestlevel smallint)
returns timestamp
begin
declare rv timestamp;
declare frm char(1);
declare mins double;
declare fnc char(100);
set rv=null;
select first hoursfrom,isnull(cascadehours,0.0)*60.0,customfunction into frm,mins,fnc from cascaderule where vacancyid = vacid and cascadelevel = requestlevel and isnull(vacancyrule,0) = 0;
if frm is null then
select first hoursfrom,isnull(cascadehours,0.0)*60.0,customfunction into frm,mins,fnc from cascaderule where companyid = compid and vacancyid is null and cascadelevel = requestlevel and isnull(vacancyrule,0) = 0
end if;
case frm when 'E' then
set rv=dateadd(Minute,mins,entrytime) when 'S' then
set rv=dateadd(Minute,0-mins,shifttime) when 'C' then
set rv=dateadd(Minute,mins,casctime) when 'X' then
set rv=dateadd(Year,150,current timestamp) when 'O' then
begin
execute immediate string('set rv=',fnc,'(compid,vacid,entrytime,shifttime,casctime,requestlevel)')
exception
when others then
set rv=dateadd(Year,150,current timestamp)
end
end case
;
return rv
end
}