====== pears.VacancyRecipientHeadline ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."VacancyRecipientHeadline"( in "vacid" char(20),in "recipid" char(20) )
returns long varchar
begin
declare "rv" long varchar;
declare "Part" long varchar;
declare "Ref" long varchar;
declare "NewLine" char(2);
set "NewLine" = "char"(13)+"Char"(10);
if "recipid" is null then
select "department"."name","string"('Our Ref. ',"vacancy"."refcode","ifnull"("vacancy"."theirref",'',' Their Ref. '),"vacancy"."theirref") into "rv","ref" from "vacancy" key join "department" where "vacancy"."vacancyid" = "vacid";
select "staff"."userid" into "part" from "vacancy" key join "staff" where "vacancy"."vacancyid" = "vacid";
set "rv" = "string"("rv",' ',"part");
select "status"."name" into "part" from "vacancy" join "status" on "status"."type" = 'V' and "status"."status" = "vacancy"."status" where "vacancy"."vacancyid" = "vacid";
set "rv" = "string"("rv",' ',"part","newline","ref")
else
set "rv" = (select "name" from "person" where "personid" = "recipid");
select "list"(' '+"number") into "Part" from "phone" where "Who" = 'P' and "phonetypeid" = 'PH' and "WhoID" = "RecipID";
if "isnull"("Part",'') <> '' then set "rv" = "string"("rv","newline",'Telephone::',"Part")
end if end if;
set "part" = '';
select "getquestanswer"('V','MAX',"VacID") into "part";
if "part" <> '' then set "rv" = "rv"+"NewLine"+'Salary Range to: '+"part"
end if;
set "Part" = '';
select "string"("ifnull"("vacancy"."clientdepartment",'','Client Department: '),"vacancy"."clientdepartment") into "part" from "vacancy" key join "department" where "vacancy"."vacancyid" = "vacid";
set "rv" = "string"("rv","newline","part");
return("rv")
end