The technical reference gives an example of a trigger on a table - employee
Just to test this, I have created the following table,
CREATE TABLE employee
(name VARCHAR(30),
age int4,
state VARCHAR(2),
manager VARCHAR(3),
adult VARCHAR(3));
The I created a simple Function, as follows :
CREATE FUNCTION trig_insert_update_check_emp() RETURNS opaque AS '
BEGIN
IF new.age > 20 THEN
new.adult = ''yes'';
ELSE
new.adult = ''no'';
END IF;
END;
' LANGUAGE 'plpgsql';
Finally, I defined the Trigger as :
CREATE TRIGGER employee_insert_update
BEFORE INSERT OR UPDATE ON employee
FOR EACH ROW EXECUTE PROCEDURE trig_insert_update_check_emp();
Now, when I execute the following :
INSERT INTO employee (name,age,state,manager)
VALUES ('sean',29,'tx','yes');
I get :
ERROR fmgr_info function 6264440 cache lookup failed
What am I doing wrong ????