pears.GetCompanyPhoneInBlock
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"."GetCompanyPhoneInBlock" IS {CREATE FUNCTION GetCompanyPhoneInBlock /* Application Maintained Function / Procedure - DO NOT EDIT*/ (IN reqcompanyid 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 = 'C' AND whoid = reqcompanyid 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 }