X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B58094758F1 for ; Sun, 23 Feb 2003 17:54:25 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 36037-05 for ; Sun, 23 Feb 2003 17:54:14 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 4BD92474E5C for ; Sun, 23 Feb 2003 17:52:44 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2853918; Sun, 23 Feb 2003 14:52:45 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "James Cooper" , "sql" Subject: Re: syntax question Date: Sun, 23 Feb 2003 14:52:00 -0800 User-Agent: KMail/1.4.3 References: <006401c2db87$fc09be00$c900a8c0@jax> In-Reply-To: <006401c2db87$fc09be00$c900a8c0@jax> MIME-Version: 1.0 Message-Id: <200302231452.00484.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/517 X-Sequence-Number: 11915 James, > FOR total IN EXECUTE subquery LOOP > > END LOOP; > > RETURN total.tot; The above is fine, except that you need to assign total.tot to a variable= =20 *inside* the loop: FOR total IN EXECUTE subquery LOOP return_total :=3D total.tot; END LOOP; RETURN return_total; This is because the expression "total.tot" is out of scope as soon as the l= oop=20 exits. --=20 Josh Berkus Aglio Database Solutions San Francisco