====== pears.NetVacancyRoleAllowed ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."NetVacancyRoleAllowed"( in "pWebUserID" char(20),in "pVacancyID" char(20),in "pVacancyRoleExternalCode" char(20) ) returns smallint begin if not exists(select * from "VacancyRoleAllocation" as "a" key join "VacancyRole" as "r" where "a"."VacancyID" = "pVacancyID" and "r"."ExternalCode" = "pVacancyRoleExternalCode") then return 1 -- Nobody assigned to this role - anyone can do end if; if exists(select * from "VacancyRoleAllocation" as "a" key join "VacancyRole" as "r","VacancyRoleAllocation" as "a" key join "employment" key join "iqxnetuserlink" as "x" where "a"."VacancyID" = "pVacancyID" and "r"."ExternalCode" = "pVacancyRoleExternalCode" and "x"."IQXNetUserID" = "pWebUserID") then return 1 end if; return 0 end