====== pears.EmployeeAcceptable ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."EmployeeAcceptable"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "persid" char(20),in "compid" char(20),in "iTemp" smallint,in "VacID" char(20) default null,in "IncludeWithheld" smallint default 0 ) returns char(1) begin declare "result" char(1); select if "IncludeWithheld" <> 1 and exists(select * from "withholds" where "personid" = "persid" and "companyid" = "compid") then 'W' else if "IncludeWithheld" <> 1 and "VacID" is not null and exists(select * from "withholds" where "VacancyID" = "VacID" and "PersonID" = "persid") then 'V' else if "IncludeWithheld" <> 1 and "VacID" is not null and exists(select * from "Person" where "ExclusiveVacancyID" <> "VacID" and "PersonID" = "persid") then 'X' else if "isnull"("itemp",0) <> 0 then null else if exists(select * from "employment" where "personid" = "persid" and "companyid" = "compid" and "temp" = 0 and "isnull"("leavedate",current date+10) > current date) then 'C' else if exists(select * from "employment" where "personid" = "persid" and "companyid" = "compid" and "temp" = 0 and "leavedate" > "dateadd"("year",-1,current date)) then 'R' else null endif endif endif endif endif endif into "result"; return "result" end