From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Kev *EXTERN*" <kevinjamesfield(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: trigger functions with arguments |
Date: | 2009-06-08 09:18:42 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C202FF6631@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Kev wrote:
> I came across this curious behaviour today, at least in the 2009-03-24
> beta (I can't run a newer beta), that I couldn't find in the docs,
> although maybe I missed it.
[...]
> So while that is the way to create the trigger itself, the
> trigger procedure must be created like this:
>
> CREATE OR REPLACE FUNCTION test() RETURNS trigger AS $BODY$
> my ($a, $b) = @{$_TD->{args}}; # $a and/or $b may be null, depending on how CREATE TRIGGER was used
> ...
Maybe it is hidden too well, but the documentation states in
http://www.postgresql.org/docs/current/static/plpgsql-trigger.html
A trigger procedure is created with the CREATE FUNCTION command, declaring it
as a function with no arguments and a return type of trigger. Note that the function
must be declared with no arguments even if it expects to receive arguments
specified in CREATE TRIGGER - trigger arguments are passed via TG_ARGV,
as described below.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2009-06-08 09:22:10 | Re: Server admin for Clients ? |
Previous Message | Ivan Sergio Borgonovo | 2009-06-08 09:16:27 | Re: why dropping a trigger may cause a deadlock |