Thread: PL/pgSQL Trigger Problems

PL/pgSQL Trigger Problems

From
"Gregory Wood"
Date:
I'm having problems getting a simple PL/pgSQL trigger to work. I suspect
that something may not be set up correctly, but I have no idea what.
Specifically, I'm trying to get the example working in the 'PL/pgSQL Trigger
Procedure' section of the documentation (located at:
http://www.postgresql.org/docs/postgres/x4418.htm )

Earlier, it was telling me that there was a Parse Error when I tried to
insert a value. Currently the error message I get is: "fmgr_info: function
4605120: cache lookup failed"

And for what it's worth, I did install plpgsql for my database as detailed
in the example in the documentation (located at:
http://www.postgresql.org/docs/postgres/xplang.htm#AEN22060 ). Specifically
I executed both the CREATE FUNCTION and CREATE TRUSTED PROCEDURAL LANGUAGE
statements.

Any help would be most appreciated.

Gregory Wood


Re: PL/pgSQL Trigger Problems

From
"Gregory Wood"
Date:
Apologies for replying directly back to you Dan, I'm used to replying back
to the list automatically... guess I got spoiled =)

Sadly, that doesn't appear to be it, unless there is something wrong with
the order of these operations:

DROP TRIGGER emp_stamp ON emp;
DROP FUNCTION emp_stamp();
DROP TABLE emp;
CREATE TABLE emp (...
CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS '...
CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp...
COMMIT;
INSERT INTO emp (empname,salary) VALUES ('John Doe',100000);

Any other suggestions?

> You dropped your function and recreated it, but did not drop your trigger.
> It is still linked to the old version of your function.  Just drop your
> trigger and recreate it and it should work fine.

> > Earlier, it was telling me that there was a Parse Error when I tried to
> > insert a value. Currently the error message I get is: "fmgr_info:
function
> > 4605120: cache lookup failed"