Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0QHVgq27049 for ; Fri, 26 Jan 2001 12:31:42 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [208.59.253.44] (HELO agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 3.3) with ESMTP id 1182626 for pgsql-sql@postgresql.org; Fri, 26 Jan 2001 09:31:41 -0800 Message-ID: <3A71B396.43FB80D@agliodbs.com> Date: Fri, 26 Jan 2001 09:27:50 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions X-Mailer: Mozilla 4.73 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: sqllist Subject: Request for change in PL/PGSQL function handler Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/386 X-Sequence-Number: 1059 Jan, Tom, etc: Currently (7.0.3) the PLPGSQL function compiler permits only one RETURN statment, at the end of the function. RETURN statements placed elsewhere cause a compile error. This, combined with the lack of an ELSEIF statement, has forced me into sometimes 7 levels of nested IF..THEN statements. WHile they work fine, they're a bit hard to read and edit. For example, say I want to test for a, b, c, or d sequentially, under the 7.0.3 compiler, I must: BEGIN IF a THEN return_text := 'One'; ELSE IF b THEN return_text := 'Two'; ELSE IF c THEN return_text := 'Three'; ELSE IF d THEN return_text := 'Four'; ELSE return_text := 'Not Found'; END IF; END IF; END IF; END IF; RETURN return_text; END; As you can see, this kind of structure gets kind of had to read and maintain for more complex statments. I have two suggested revisions to the compiler that would make this much easier: SUGGESTION A: Support of an ELSEIF statement, as: IF a THEN return_text := 'One'; ELSEIF b THEN return_text := 'Two'; ELSIF c THEN return_text := 'Three'; ...etc. SUGGESTION B: Allow more than one RETURN statment in the function text, with funciton processing to terminate as soon as a RETURN is reached in the program logic, but otherwise be ignored: IF a THEN RETURN 'One'; END IF; IF b THEN RETURN 'Two'; END IF; ...etc. Both approaches would, from my perspective, make my code easier to read and maintain. And, of course, you may have already implemented one or the other in 7.1 (which I have not yet got to run on an alternate port). Thanks for your hard work and consideration towards us users. -Josh Berkus -- ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 436-9166 for law firms, small businesses fax 436-0137 and non-profit organizations. pager 338-4078 San Francisco