From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Josh Close <narshe(at)gmail(dot)com> |
Cc: | POSTGRES <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: plpgsql loop not returning value |
Date: | 2004-10-16 06:59:34 |
Message-ID: | 20041016065934.GA19210@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Oct 15, 2004 at 10:56:06PM -0500, Josh Close wrote:
> FOR this_rSum IN EXECUTE this_sQuery LOOP
> this_iSum := this_rSum.isum;
> END LOOP;
> this_iTotal := this_iTotal + this_iSum;
[snip]
> If I return this_iSum or this_iTotal in the loop, I get a value. If I
> return directly after the loop, the value is NULL. I can't figure out
> why it's doing this. The value comes out of the inside for loop just
> fine, but not the outer loop.
Add some RAISE INFO statements to print variables' values at key
places. I wonder if one of your SUMs is returning NULL, causing
your addition to evaluate to NULL. If so, then perhaps you should
use COALESCE to turn those NULLs into zeros.
If I've misunderstood the problem then please clarify.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Katsaros Kwn/nos | 2004-10-16 10:40:26 | Re: Networking feature for postgresql... |
Previous Message | William Yu | 2004-10-16 05:57:43 | Re: creating audit tables |