Re: Function result using execute

From: Paul Lambert <paul(dot)lambert(at)reynolds(dot)com(dot)au>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Function result using execute
Date: 2007-12-12 06:30:06
Message-ID: 475F7FEE.2060305@reynolds.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2007-12-12 06:31:42 Re: Query design assistance - getting daily totals
Previous Message Erik Jones 2007-12-12 06:25:10 Re: Function result using execute