====== pears.MasterRosterTempAllowed ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."MasterRosterTempAllowed"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "ppersid" char(20),in "pmastershiftid" char(20) )
returns integer
begin
declare "ionly" integer;
declare "iactive" integer;
if "pmastershiftid" is null then
return 1
end if;
if "ppersid" = (select "defaultpersonid" from "masterrostershift" where "masterrostershiftid" = "pmastershiftid") then
return 1
end if;
select "isnull"("r"."useonlypreferred",0),"isnull"("p"."active",0) into "ionly","iactive"
from "masterrostershift" as "s" key join "masterroster" as "r" left outer join "MasterRosterPreferredPerson" as "p"
on "r"."MasterRosterID" = "p"."MasterRosterID" and "p"."PersonID" = "ppersid"
where "s"."masterrostershiftid" = "pmastershiftid";
if "ionly" = 0 then
return 1
else
return "iactive"
end if
end