====== pears.contactlink ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."contactlink" IS
{create function contactlink
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in sempid char(20),in spersid char(20),in sfromwho char(1),in stowho char(1))
returns char(50)
begin
declare rv char(50);
if(sempid is null or spersid is null) and not(sfromwho = 'A' and spersid is null) then
return('')
end if;
set rv='';
if sfromwho = 'A' then
set rv=(select company.name from company key join employment where employment.employmentid = sempid);
set rv="char"(58)+' '+rv;
if stowho = 'C' or spersid is null then
set rv='To' || rv
elseif stowho = 'A' then
set rv='Re' || rv
else
set rv='With' || rv
end if
else
set rv=(select person.name from person where person.personid = spersid);
set rv="char"(58)+' '+rv;
if stowho = 'A' then
set rv='To' || rv
elseif stowho = 'C' then
set rv='Re' || rv
else
set rv='With' || rv
end if
end if;
return(rv)
end
}