pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sigi Jekabsons <sigi.j@workskillsprofessionals.com.au>
To: pgsql-sql@postgresql.org
Subject: trouble creating trigger
Date: Tue, 22 Apr 2003 10:28:24 +0800
Message-ID: <006e01c30876$d9ddf0f0$0302a8c0@microvac> (raw)

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.




view thread (3+ messages)  latest in thread

Message-ID: <006e01c30876$d9ddf0f0$0302a8c0@microvac>
Permalink:  ../006e01c30876$d9ddf0f0$0302a8c0@microvac/
Also on:    postgresql.org/message-id/006e01c30876$d9ddf0f0$0302a8c0@microvac

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sigi.j@workskillsprofessionals.com.au
  Subject: Re: trouble creating trigger
  In-Reply-To: <006e01c30876$d9ddf0f0$0302a8c0@microvac>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox