Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id AE5472E3610 for ; Wed, 12 Dec 2007 02:30:32 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00820-01 for ; Wed, 12 Dec 2007 02:30:30 -0400 (AST) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by postgresql.org (Postfix) with ESMTP id 862132E3203 for ; Wed, 12 Dec 2007 02:30:28 -0400 (AST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (authenticated sender plengada@optusnet.com.au) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id lBC6UNGb031800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 Dec 2007 17:30:26 +1100 Message-ID: <475F7FEE.2060305@reynolds.com.au> Date: Wed, 12 Dec 2007 15:30:06 +0900 From: Paul Lambert User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: pgsql-sql Subject: Re: Function result using execute References: <475F6E69.3060207@reynolds.com.au> <12742.1197439311@sss.pgh.pa.us> In-Reply-To: <12742.1197439311@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/64 X-Sequence-Number: 29756 Tom Lane wrote: > Do you really need an EXECUTE? If so, maybe you could restructure this > using a FOR ... IN EXECUTE, or some such thing. I'll always only ever have a single result since the function gets passes all the fields making up the primary key of the table, so doing a for in seems like it's doing more work than is needed. I need an execute because I'm dynamically constructing an SQL statement based on the parameters passed into the function - unless there is some other way of doing it that I'm not aware of. > >> therefore I just be using a test of IF curr_amount IS NOT NULL? > > Well, that might work. Have you thought through the corner case > where the query does find a row but the field's value is null? > The field in question is marked not null in the tables schema, so unless PG lets things get past this constraing I don't believe that would be an issue. Having the test at is not null seems to be doing the job. Thanks. -- Paul Lambert Database Administrator AutoLedgers - A Reynolds & Reynolds Company