====== pears.GetPersonEmploymentHistory ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."GetPersonEmploymentHistory"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "InPersonID" char(20),in "Word" char(3) ) returns long varchar begin declare "EmploymentHistory" long varchar; declare "Tab" char(1); declare "NewLine" char(2); declare "LoopCounter" tinyint; -- Word does not like CR LF, just CR if "Word" = 'Yes' then set "NewLine" = "char"(13) else set "NewLine" = "char"(13)+"char"(10) end if; set "Tab" = "char"(9); set "LoopCounter" = 0; set "EmploymentHistory" = ''; for "fetchfor" as "fetchcursor" no scroll cursor for select "dateformat"("Employment"."StartDate",'Mmm yyyy')+"Tab"+"dateformat"("Employment"."LeaveDate",'Mmm yyyy') +"Tab"+"Company"."Name"+"Tab"+"Employment"."Position" as "NextLine" from "Employment" key join "Company" where "temp" = 0 and "Employment"."StartDate" is not null and "Employment"."PersonID" = "InPersonID" order by "Employment"."StartDate" desc for read only do if "LoopCounter" > 0 then set "EmploymentHistory" = "EmploymentHistory" || "NewLine" end if; set "EmploymentHistory" = "EmploymentHistory" || "NextLine"; set "LoopCounter" = "LoopCounter"+1 end for; return("EmploymentHistory") end