Dynamic Assignment

Поиск
Список
Период
Сортировка
От Andy Chambers
Тема Dynamic Assignment
Дата
Msg-id op.vss12610cqhz04@vaio.mcnaitdept
обсуждение исходный текст
Ответы Re: Dynamic Assignment  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
Hi All,

In a trigger function, I'm trying to set the variable "pkey" to be one of
the columns
in the automatic variable "NEW".  Which one depends on some metadata that
is available at
run-time.  I'm having a hard time using an automatic variable in a dynamic
execute command.

I get the error "missing FROM-clause entry for table "new""

Here's my function

create or replace function refresh_row () returns trigger as $$

declare
   pkey bigint;
begin
   execute 'select NEW.esid' into pkey;
end;
$$ language plpgsql

Obviously this particular code could be re-written as a simple assignment
but I need the
"esid" part to be dynamic.  Is this possible?

Cheers,
Andy

--
Andy Chambers

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Recursive function that receives a list of IDs and returns all child IDs
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Dynamic Assignment