pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Paul Lambert <paul.lambert@reynolds.com.au>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Function result using execute
Date: Wed, 12 Dec 2007 01:01:51 -0500
Message-ID: <12742.1197439311@sss.pgh.pa.us> (raw)
In-Reply-To: <475F6E69.3060207@reynolds.com.au>
References: <475F6E69.3060207@reynolds.com.au>

Paul Lambert <paul.lambert@reynolds.com.au> writes:
> The relevant part of the code looks like thus:
>     EXECUTE curr_query INTO curr_amount;
>     RAISE NOTICE '%',curr_amount;
>     IF NOT FOUND THEN
>        curr_amount=0;
>     END IF;

> ... which suggests to me that although the 
> execute has populated the curr_amount field with something, the IF NOT 
> FOUND is always firing.

IIRC, the EXECUTE command does not change FOUND --- leastwise it's not
listed as one of the plpgsql commands that do set FOUND.

Do you really need an EXECUTE?  If so, maybe you could restructure this
using a FOR ... IN EXECUTE, or some such thing.

> 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?

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <12742.1197439311@sss.pgh.pa.us>
Permalink:  ../12742.1197439311@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12742.1197439311@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, paul.lambert@reynolds.com.au
  Subject: Re: Function result using execute
  In-Reply-To: <12742.1197439311@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox