Re: triggers and TriggerData

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Alan Hodgson <ahodgson(at)simkin(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: triggers and TriggerData
Date: 2007-01-22 15:04:37
Message-ID: 20070122150437.GA65433@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jan 21, 2007 at 09:05:30PM -0800, Alan Hodgson wrote:
> On Sunday 21 January 2007 15:56, gustavo halperin <ggh(dot)develop(at)gmail(dot)com> wrote:
> > I have another question about triggers, how can I pass arguments ?? I
> > read about some struct TriggerData *CurrentTriggerData, but I didn't
> > found any explanation or example about how to use it in postgres SQL.
> > My problem is that for any INSERT row in table 'B' I need to pass
> > to the function trigger two values of this row. Do you know how to
> > do so or where are examples of how to do it ??
>
> You cannot pass values to a trigger.

You can pass literal string arguments to a trigger function. See
the CREATE TRIGGER documentation and, for PL/pgSQL, TG_ARGV and
TG_NARGS. For C see "Writing Trigger Functions in C"; search for
tgnargs and tgargs.

http://www.postgresql.org/docs/8.2/interactive/sql-createtrigger.html
http://www.postgresql.org/docs/8.2/interactive/plpgsql-trigger.html
http://www.postgresql.org/docs/8.2/interactive/trigger-interface.html

(These links are to the 8.2 documentation but earlier versions also
support arguments to trigger functions.)

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-01-22 15:11:23 Re: Loop in loop
Previous Message Moritz Bayer 2007-01-22 14:58:32 Re: Loop in loop