====== pears.GetPersonPhoneInBlock ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."GetPersonPhoneInBlock"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "reqpersonid" char(20) )
returns long varchar
begin
declare "phones" long varchar;
declare "newline" char(2);
declare "loopcounter" tinyint;
declare "tab" char(1);
declare "TabString" char(2);
set "newline" = "char"(13)+"char"(10);
set "phones" = '';
set "loopcounter" = 0;
set "tab" = "char"(9);
for "fetchfor" as "fetchcursor" no scroll cursor for
select "phonetype"."name" as "nextname","phone"."number" as "nextnumber" from "phone"
key join "phonetype" where "phone"."who" = 'P' and "whoid" = "reqpersonid"
order by "phone"."whoid" asc,"phonetype"."sortorder" asc,"phonetype"."name" asc for read only do
if "loopcounter" > 0 then
set "phones" = "phones" || "newline"
end if;
if "length"("nextname") < 8 then set "TabString" = "Tab"+"Tab"
else set "TabString" = "Tab"
end if;
set "phones" = "phones" || "nextname" || "TabString" || "nextnumber";
set "loopcounter" = "loopcounter"+1 end for;
return "phones"
end