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