Re: Retrieving a field from the NEW record

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Retrieving a field from the NEW record
Дата
Msg-id 20050119032116.GA56080@winnie.fuhr.org
обсуждение исходный текст
Ответ на Retrieving a field from the NEW record  (Eric E <whalesuit@bonbon.net>)
Ответы Re: Retrieving a field from the NEW record  (Eric E <whalesuit@bonbon.net>)
Список pgsql-general
On Tue, Jan 18, 2005 at 04:21:51PM -0500, Eric E wrote:

>    I'm tearing my hair out trying to solve the following problem.  I
> want to be able to retrieve the value of the primary key in a trigger
> function.  I have tried using PL/PGSQL and PL/PERL, but a PL/PERL
> trigger function crashes the postgress process.

What versions of PostgreSQL and Perl are you using?  If the backend
is crashing then check to see if the bug has been fixed in a newer
version of PostgreSQL.  If not then please submit a bug report with
a repeatable test case.

I wrote a simple PL/Perl trigger in 8.0.0 and was able to access
$_TD->{new}{$pk}, where $pk held the name of a column.  Maybe the
bug has been fixed in the latest code.

> In other words, I want:
>
> NEW.pkName, where pkName is a variable holding the name of my primary key.

I'm not aware of a way to do this in a PL/pgSQL trigger.  I didn't
think EXECUTE would work and indeed it doesn't, at least not the
way I tried:

ERROR:  NEW used in query that is not in a rule

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: "Rick Schumeyer"
Дата:
Сообщение: Easy transaction question
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Multiline plpython procedure