====== pears.AWRPlacement ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."AWRPlacement"( in "vacid" char(20),in "persid" char(20),in "shiftid" char(20) )
returns char(20)
begin
declare "rv" char(20);
-- finds placementid for use in AWR
set "rv" = null;
if "shiftid" is not null then
select "placementid" into "rv" from "tempshift" where "tempshiftid" = "shiftid"
end if;
if "rv" is null then
select first "placementid" into "rv" from "placement" key join "employment" where "personid" = "persid" and "vacancyid" = "vacid" order by "isnull"("employment"."leavedate",current date+3650) desc
end if;
if "rv" is null then
-- set rv = uniquekey(persid);
-- insert into placement () values () ;
-- might create one and return ID ???
end if;
return "rv"
end