From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "Guillaume Bog" <guibog(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: pl/pgsql RECORD data type, how to access to the values |
Date: | 2008-04-05 08:05:11 |
Message-ID: | 162867790804050105ga14ba5vf32bfc5ac8a987c8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
On 05/04/2008, Guillaume Bog <guibog(at)gmail(dot)com> wrote:
> Hello,
>
> I'm writing a trigger in pl/pgSQL and I'd like to pass one column name as
> argument to the trigger function.
>
> Provided my table has only one column named 'id', I can do easilly
>
> CREATE FUNCTION ft() RETURNS trigger AS $$
> BEGIN
> RAISE NOTICE 'It works:%', OLD.id;
> END
> $$ LANGUAGE plpgsql;
>
> But I'd like to do
>
> CREATE FUNCTION ft() RETURNS trigger AS $$
> DECLARE
> col VARCHAR;
> BEGIN
> col = TG_ARGV[0]
> RAISE NOTICE 'This does not works:%', OLD.col
> RAISE NOTICE 'This also does not works:%', OLD[col]
> END
> $$ LANGUAGE plpgsql;
>
> I tried OLD.(col) and other tricks, like "SELECT INTO" or "EXECUTE", and I
> checked the docs.
It's not possible in plpgsql. You have to use plperl, pltcl or plpython.
Regards
Pavel Stehule
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tomasz Ostrowski | 2008-04-05 09:39:33 | Re: simple update queries take a long time - postgres 8.3.1 |
Previous Message | Thomas Pundt | 2008-04-05 07:52:11 | Re: Word boundaries in regular expressions |