X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 45946D1B97B for ; Thu, 26 Feb 2004 10:20:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 65174-01 for ; Thu, 26 Feb 2004 06:20:31 -0400 (AST) Received: from zeth.webonline.biz (zeth.webonline.biz [196.7.217.139]) by svr1.postgresql.org (Postfix) with ESMTP id DEDD5D1B90C for ; Thu, 26 Feb 2004 06:20:23 -0400 (AST) Received: from phil (nld-dial-196-30-177-92.mweb.co.za [196.30.177.92]) by zeth.webonline.biz (8.12.9/8.12.9) with SMTP id i1QAWVa1002833 for ; Thu, 26 Feb 2004 12:32:32 +0200 Reply-To: From: "Philip J. Boonzaaier" To: Subject: Triggers Date: Thu, 26 Feb 2004 12:18:57 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/392 X-Sequence-Number: 17082 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 ????