Re: plpgsql loop not returning value

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: plpgsql loop not returning value
Дата
Msg-id 20041016065934.GA19210@winnie.fuhr.org
обсуждение исходный текст
Ответ на plpgsql loop not returning value  (Josh Close <narshe@gmail.com>)
Ответы Re: plpgsql loop not returning value  (Josh Close <narshe@gmail.com>)
Список 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/

В списке pgsql-general по дате отправления:

Предыдущее
От: William Yu
Дата:
Сообщение: Re: creating audit tables
Следующее
От: "Katsaros Kwn/nos"
Дата:
Сообщение: Re: Networking feature for postgresql...