From: | "Karl O(dot) Pinc" <kop(at)meme(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | plpgsql trigger function with arguments |
Date: | 2004-03-03 03:35:27 |
Message-ID: | 20040302213527.E3302@mofo.meme.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm sure I saw something like this on the postgresql web
site but the the search function is down in the documentation
area.
I'm unable to pass a function arguments in a CREATE
TRIGGER statement.
What am I doing wrong here?
CREATE FUNCTION pregs_func (VARCHAR(15))
RETURNS trigger
LANGUAGE plpgsql
AS '
DECLARE
trigger_type ALIAS FOR $1;
BEGIN
IF trigger_type = ''insert'' THEN
...
END IF;
END;
';
CREATE TRIGGER pregs_insert_trigger
AFTER INSERT
ON pregs FOR EACH ROW
EXECUTE PROCEDURE pregs_func('insert');
CREATE TRIGGER pregs_update_trigger
AFTER UPDATE
ON pregs FOR EACH ROW
EXECUTE PROCEDURE pregs_func('update');
The CREATE TRIGGER statements return:
ERROR: CreateTrigger: function pregs_func() does not exist
I tried doing variations on:
create trigger pregs_insert_trigger after insert on pregs
for each row execute procedure
pregs_func (cast('insert' as varchar(15)));
thinking that I don't have the right function because the
datatypes don't match, but I get:
ERROR: parser: parse error at or near "cast" at character 106
PostgreSQL 7.3.
Thanks,
Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
From | Date | Subject | |
---|---|---|---|
Next Message | Karl O. Pinc | 2004-03-03 03:38:30 | Re: constraints |
Previous Message | Joe Conway | 2004-03-03 03:16:02 | Re: Max/min of 2 values function, plpgsql efficency? |