X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C58EA9DC83C for ; Wed, 22 Mar 2006 18:39:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77088-01 for ; Wed, 22 Mar 2006 18:39:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from nelson.osl.com (216-21-133-120.ip.van.radiant.net [216.21.133.120]) by postgresql.org (Postfix) with ESMTP id 750D09DCB80 for ; Wed, 22 Mar 2006 18:39:12 -0400 (AST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: Re: OUT parameter Date: Wed, 22 Mar 2006 14:39:13 -0800 Message-ID: <144D12D7DD4EC04F99241498BB4EEDCC25EAD1@nelson.osl.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: OUT parameter Thread-Index: AcZOAMSeQhdYW7YETu2PG21cRHNJ0gAAE+iw From: "Owen Jacobson" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.191 required=5 tests=[AWL=0.191] X-Spam-Score: 0.191 X-Spam-Level: X-Archive-Number: 200603/372 X-Sequence-Number: 24718 Daniel Caune wrote: > Is there any suggestion against using OUT parameter for local > calculation such as using a local variable? >=20 > CREATE OR REPLACE FUNCTION foo(a IN int, > b1 OUT int, > b2 OUT int) > AS $$ > BEGIN > FOR (...) LOOP > b1 =3D (...); > b2 =3D (...); > END LOOP; > END; > $$ LANGUAGE PLPGSQL; I'd say there's no problem with this, PROVIDED you can ensure you'll = never abort before completing the computation. It's not a good idea to = modify out parameters partway; programmers (myself included) have this = nasty habit of assuming, rightly or wrongly, that a failed function call = won't have destroyed the parameters. If you can't ensure you'll always complete, use locals. -Owen