Indirect access to NEW or OLD records

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Indirect access to NEW or OLD records
Date: 2008-09-25 17:42:45
Message-ID: d7df81620809251042r54318b24lc70cbe9b3f553b3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

I have a variable with a field name and want to extract this field
value from NEW record:

DECLARE
field VARCHAR = 'some_field';
BEGIN
...
value := NEW.{field}; -- ???
END;

Is it possible in pl/pgsql?

I have found one speed-inefficient solution: convert NEW to string and
then - use EXECURE with customly-build query to extract a value from
that constant string. But it is too slow. Is there better solution?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-09-25 17:42:51 Re: Counting rows in a PL/PgSQL CURSOR without fetching?
Previous Message Reg Me Please 2008-09-25 17:30:27 Dynamically created cursors vanish in PLPgSQL