====== pears.GetTimeSheetDescription ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."GetTimeSheetDescription"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "usesecags" tinyint,in "persid" char(20),in "secagid" char(20),in "sdescrip" long varchar )
returns long varchar
begin
if "isnull"("usesecags",0) = 0 or "persid" is null then
return "isnull"("sdescrip",'')
end if;
if "secagid" is null then
select first "secondaryagencyid" into "secagid" from "pay_employee" where "personid" = "persid"
end if;
if "secagid" is not null then
set "sdescrip" = "string"((select first "name" from "company" where "companyid" = "secagid"),' ',"sdescrip")
end if;
return "isnull"("sdescrip",'')
end