Function result using execute

Поиск
Список
Период
Сортировка
От Paul Lambert
Тема Function result using execute
Дата
Msg-id 475F6E69.3060207@reynolds.com.au
обсуждение исходный текст
Ответы Re: Function result using execute
Re: Function result using execute
Список pgsql-sql
I have a function which uses execute to populate the value of a variable 
based on a defined select construct.

The relevant part of the code looks like thus:   EXECUTE curr_query INTO curr_amount;   RAISE NOTICE '%',curr_amount;
IFNOT FOUND THEN      curr_amount=0;   END IF;   RAISE NOTICE '%',curr_amount;
 

I've added the if found to trap if nothing is returned by the execute so 
that the value gets set to a default 0 rather than null.

When I call the function, the first raise notice gives me a value that 
is correct based on the select it would be performing, but the second 
raise notice gives me a 0, which suggests to me that although the 
execute has populated the curr_amount field with something, the IF NOT 
FOUND is always firing.

Am I misunderstanding what the FOUND variable can be used for - i.e. is 
it not compatible with/not set by the EXECUTE command and should 
therefore I just be using a test of IF curr_amount IS NOT NULL?

Cheers,
Paul.

-- 
Paul Lambert
Database Administrator
AutoLedgers - A Reynolds & Reynolds Company


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: join on three tables is slow
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Function result using execute