Skip site navigation (1) Skip section navigation (2)

triggers with parameters

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 (view raw or flat)
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


pgsql-novice by date

Next:From: Horst HerbDate: 2001-07-30 11:37:45
Subject: access transaction log
Previous:From: Joel BurtonDate: 2001-07-28 14:31:32
Subject: Re: Get name of columns in a table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group