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