Re: Parameters from trigger to function.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vams <vmudrageda(at)charter(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Parameters from trigger to function.
Date: 2004-06-23 05:01:50
Message-ID: 26953.1087966910@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vams <vmudrageda(at)charter(dot)net> writes:
> CREATE OR REPLACE FUNCTION id_protect(text) RETURNS TRIGGER AS '
> ...
> CREATE TRIGGER protector BEFORE INSERT OR UPDATE ON testing FOR EACH ROW
> EXECUTE PROCEDURE id_protect('testing_id_seq');

> ERROR: function id_protect() does not exist

> Now, why am I getting that error?

Trigger functions *never* take any normal parameters.

You can put parameters into the CREATE TRIGGER command, but they are
passed via a different mechanism (in plpgsql, it's an array called
tg_argv[]). This is a bit weird but I think it goes along well with
the fact that triggers get a whole bunch of parameters, and from time
to time we add some. We could not do that without breaking every
existing user trigger if the parameters were all to be declared as
explicit function parameters.

See http://www.postgresql.org/docs/7.4/static/plpgsql-trigger.html
for more ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-06-23 05:11:50 Re: Datatype sizes; a space and speed issue?
Previous Message Alvaro Herrera 2004-06-23 04:51:39 Re: Datatype sizes; a space and speed issue?