Skip site navigation (1) Skip section navigation (2)

Re: trigger not firing

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: joseph speigle <joesp(at)sirfsup(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: trigger not firing
Date: 2007-02-26 03:21:30
Message-ID: 20070225191808.N40408@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Mon, 26 Feb 2007, joseph speigle wrote:

>
> hello novice list,
> can somebody show me where my mistake is with this trigger.
> everything is fine, but they don't fire......
>
> [postgres(at)www ~]$ pg_ctl --version
> pg_ctl (PostgreSQL) 8.1.3
> [postgres(at)www ~]$
>
> ---------------------------------------------------------------------
> drop function qp_question_moddate() cascade ;
>
> CREATE FUNCTION  qp_question_moddate()  RETURNS  OPAQUE
> AS '
> BEGIN
>
>   NEW.moddate := current_date;
>   RETURN  NEW;
> END;
> ' LANGUAGE 'plpgsql';
>
> create trigger qp_question_moddate_update after update on qp_question
> for each row execute procedure qp_question_moddate();

After triggers are too late for modifying NEW (since the record is already
created or changed), you'd need to make it a before trigger.

In response to

Responses

pgsql-novice by date

Next:From: Piotr PrzeworskiDate: 2007-02-26 09:26:59
Subject: postgresql-server-8.2.3-1mdv2007.1.i586.rpm installation problem
Previous:From: joseph speigleDate: 2007-02-26 01:45:59
Subject: trigger not firing

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group