Skip site navigation (1) Skip section navigation (2)

Re: Trigger and arguments question

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Hervé Inisan <typo3(at)self-access(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger and arguments question
Date: 2005-05-26 20:34:34
Message-ID: c2d9e70e050526133414d55df1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
On 5/26/05, Hervé Inisan <typo3(at)self-access(dot)com> wrote:
> 
> Hi everybody!
> 
> I have a trigger like this:
> 
> CREATE TRIGGER mytrigger
>    AFTER INSERT OR UPDATE OR DELETE
>    ON myschema.mytable
>    FOR EACH ROW
>    EXECUTE PROCEDURE myschema.myfunction(myarg);
> 
> It sends an argument to myfunction(), and I can retrieve this value in
> TG_ARGV[0]. Fine.
> What I'm trying to do is using TG_ARGV[0] to point to a field in NEW or OLD.
> Is it possible?
> 
> Something like NEW.TG_ARGV[0]...
> 
> I'm trying to write a kind of generic function which I could use on multiple
> tables with different field names (myarg being the field name).
> But I can't get it to work.
> 
> Any clues or other solutions?
No. the argument of the trigger must be a string literal defined at
creation time.

maybe you better solution is simply a function

-- 
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

pgsql-general by date

Next:From: Hrishikesh DeshmukhDate: 2005-05-26 21:04:37
Subject: Just a crazy idea!
Previous:From: Tom LaneDate: 2005-05-26 20:29:44
Subject: Re: another failover testing question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group