X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B1DEC475A8D for ; Mon, 21 Apr 2003 22:29:09 -0400 (EDT) Received: from workskillsprofessionals.com.au (workskill-lnk.qiservices.com.au [202.181.72.90]) by postgresql.org (Postfix) with ESMTP id 51D97474E42 for ; Mon, 21 Apr 2003 22:29:07 -0400 (EDT) Received: from microvac [192.168.1.124] by workskillsprofessionals.com.au [192.168.1.188] with SMTP (MDaemon.PRO.v4.0.5.R) for ; Tue, 22 Apr 2003 10:35:53 +0800 Message-ID: <006e01c30876$d9ddf0f0$0302a8c0@microvac> From: "Sigi Jekabsons" To: Subject: trouble creating trigger Date: Tue, 22 Apr 2003 10:28:24 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-MDRemoteIP: 192.168.1.124 X-Return-Path: sigi.j@workskillsprofessionals.com.au X-MDaemon-Deliver-To: pgsql-sql@postgresql.org X-Spam-Status: No, hits=-2.5 required=5.0 tests=BAYES_20,UPPERCASE_25_50 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/314 X-Sequence-Number: 13015 I can create the function the trigger is calling, and I can use the function in a SELECT, and it all works fine, but postgres won't let me create a trigger using that function. Here I'm creating the function: asp_employ=# CREATE FUNCTION upd_act_date(int4) RETURNS INTEGER AS ' asp_employ'# DECLARE asp_employ'# cand_id_arg ALIAS FOR $1; asp_employ'# BEGIN asp_employ'# UPDATE cands SET actlog_updated_last = ( SELECT MAX(date_logged) FROM cand_log WHERE cand_id = cand_id_arg ) WHERE cand_id = cand_id_arg; asp_employ'# RETURN 1; asp_employ'# END; asp_employ'# ' LANGUAGE 'plpgsql'; CREATE FUNCTION And the function appears to work okay: asp_employ=# SELECT upd_act_date('003234'); upd_act_date -------------- 1 (1 row) However I can't create the trigger: asp_employ=# CREATE TRIGGER upd_act_date_tg asp_employ-# BEFORE INSERT OR UPDATE ON cand_log FOR EACH ROW asp_employ-# EXECUTE PROCEDURE upd_act_date(cand_id); ERROR: CreateTrigger: function upd_act_date() does not exist This doesn't work either: asp_employ=# CREATE TRIGGER upd_act_date_tg asp_employ-# AFTER INSERT OR UPDATE ON cand_log asp_employ-# FOR EACH ROW EXECUTE PROCEDURE upd_act_date('003234'); ERROR: CreateTrigger: function upd_act_date() does not exist What am I doing wrong? This is on Postgres 7.3.2 on debian.