triggers with parameters - Mailing list pgsql-novice

From Bryan Buchanan
Subject triggers with parameters
Date
Msg-id 3B63721A.4F2BF4FC@webbtide.com.au
Whole thread Raw
List 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


pgsql-novice by date:

Previous
From: Joel Burton
Date:
Subject: Re: Get name of columns in a table
Next
From: Horst Herb
Date:
Subject: access transaction log