unique names in variables and columns in plsql functions

Поиск
Список
Период
Сортировка
От Wiebe Cazemier
Тема unique names in variables and columns in plsql functions
Дата
Msg-id 4427F7D3.3000103@gmail.com
обсуждение исходный текст
Ответы Re: unique names in variables and columns in plsql functions  ("Jim C. Nasby" <jnasby@pervasive.com>)
Re: unique names in variables and columns in plsql functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi,

In a plpgsl function, consider the following excerpt:

DECLARE provider_id INTEGER;
BEGIN provider_id := (SELECT provider_id FROM investment_products WHERE id =
my_new.investment_product_id);
END;

After a lot of trouble, I found out this line doesn't work correctly
with the variable name as it is. It doesn't give an error or anything,
it just retrieves some wrong value (probably NULL). When I change the
variable name to anything other than "provider_id", it works OK.

I was somewhat surprised to discover this. Can't Postgres determine that
the provider_id in the SELECT statement is not the same one as the variable?

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

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Problem using set-returning functions
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: unique names in variables and columns in plsql functions