| From: | Bryan Buchanan <bryanb(at)webbtide(dot)com(dot)au> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | triggers with parameters |
| Date: | 2001-07-29 02:16:58 |
| Message-ID: | 3B63721A.4F2BF4FC@webbtide.com.au |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
Hi,
I'm having trouble getting a trigger to use a parameter, as in the
following simplified example:
CREATE FUNCTION build_xref(text)
RETURNS opaque
AS 'DECLARE
tablename text;
BEGIN
tablename := upper($1);
-- do something in here
RETURN new;
END;'
LANGUAGE 'plpgsql';
CREATE TRIGGER credit_terms_xref_trigger
AFTER INSERT
ON credit_terms
FOR EACH ROW
EXECUTE PROCEDURE build_xref('credit_terms');
When I do an insert to the credit_terms table I get an error:
ERROR: function has no parameter $1
I've created triggers/functions with no parameters and they work fine.
The Postgresql book has some examples of functions with paramters, but
I cannot find anywhere a trigger which calls a function with parameters,
although the users manual indicates that parameters are allowed in the
syntax for CREATE TRIGGER.
Bryan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Horst Herb | 2001-07-30 11:37:45 | access transaction log |
| Previous Message | Joel Burton | 2001-07-28 14:31:32 | Re: Get name of columns in a table |