From: | Vams <vmudrageda(at)charter(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Parameters from trigger to function. |
Date: | 2004-06-23 03:46:38 |
Message-ID: | 200406222346.39006.vmudrageda@charter.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Everyone, I need your help,
I am trying to pass a parameter to a function that is to be called by a
trigger. But, the correct function isn't being recognized and I am getting
an error stating that the function doesn't exist even though it does!
What I got going in psql...
CREATE TABLE testing (id SERIAL, data text); -- sequence = testing_id_seq
CREATE OR REPLACE FUNCTION id_protect(text) RETURNS TRIGGER AS '
DECLARE
sequence ALIAS FOR $1;
BEGIN
IF TG_OP = ''INSERT'' THEN
NEW.id := nextval(sequence);
RETURN NEW;
ELSIF TG_OP = ''UPDATE'' THEN
NEW.id := OLD.id;
RETURN NEW;
ELSE
RETURN NEW;
END IF;
END;
' LANGUAGE PLPGSQL;
\df id_protect
List of Functions
Result data type | Schema | Name | Argument data types
-------------------+----------+------------+------------------------
"trigger" | public | id_protect | text
CREATE TRIGGER protector BEFORE INSERT OR UPDATE ON testing FOR EACH ROW
EXECUTE PROCEDURE id_protect('testing_id_seq');
ERROR: function id_protect() does not exist
-----------------------------------------------------------------------------------------------------
Now, why am I getting that error?
Thx all,
Vams
From | Date | Subject | |
---|---|---|---|
Next Message | mike g | 2004-06-23 03:51:42 | Re: incremental backups? |
Previous Message | Joel Matthew | 2004-06-23 03:28:27 | incremental backups? |