Re: Indirect access to NEW or OLD records

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dmitry(at)koterov(dot)ru
Cc: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Indirect access to NEW or OLD records
Date: 2008-09-25 18:08:58
Message-ID: 9644.1222366138@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Dmitry Koterov" <dmitry(at)koterov(dot)ru> writes:
> 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?

No. Quite aside from the lack of syntax for that, plpgsql would be
unhappy if the data type wasn't the same on successive executions.

Use one of the less strongly typed PLs instead. I believe this is
pretty easy in plperl or pltcl. (Maybe plpython too, but I don't know
that language.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message zach cruise 2008-09-25 18:09:13 ease of use sync
Previous Message Casey Allen Shobe 2008-09-25 18:07:37 Re: Oracle and Postgresql