pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <JanWieck@Yahoo.com>
To: miker@purplefrog.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Trigger problem
Date: Wed, 09 Jun 2004 21:44:36 -0400
Message-ID: <40C7BD04.1040105@Yahoo.com> (raw)
In-Reply-To: <ca52p7$2sbn$1@news.hub.org>
References: <BJnxc.1978$_s7.121@news.get2net.dk>
	<ca52p7$2sbn$1@news.hub.org>

On 6/8/2004 2:57 PM, Mike Rylander wrote:

> kasper wrote:
> 
>> Hi guys
>> 
>> Im tryint to make a trigger that marks a tuble as changed whenever someone
>> has updated it
>> 
>> my table looks something like this
>> 
>> create table myTable (
>>     ...
>>     changed boolean;
>> )
>> 
>> now ive been working on a trigger and a sp that looks like this, but it
>> doesnt work...
>> 
>> create function myFunction returns trigger as '
>>     begin
>>         new.changed = true;
> 
> The line above is using the SQL equaliy opperator, you want the assignment
> operator:
> 
>   :=
> 
> as in 
> 
>         new.changed := true;

PL/pgSQL accepts both. What's wrong is that it's an AFTER trigger, which 
is fired AFTER the new row is already stored on disk and thus cannot 
change it any more.


Jan

> 
>>         return new;
>>     end;
>> ' language 'plpgsql';
>> 
>> create trigger myTrigger
>> after update on lektioner
>> for each row
>> execute procedure myFunction();
>> 
>> 
>> the code compiles, runs, and doesnt whine about anything, but nothing
>> changes...
>> 
>> any ideas??
>> 
>> - Kasper
> 
> -miker
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings


-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #




view thread (10+ messages)  latest in thread

Message-ID: <40C7BD04.1040105@Yahoo.com>
Permalink:  ../40C7BD04.1040105@Yahoo.com/
Also on:    postgresql.org/message-id/40C7BD04.1040105@Yahoo.com

 · 

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: JanWieck@Yahoo.com, miker@purplefrog.com
  Subject: Re: Trigger problem
  In-Reply-To: <40C7BD04.1040105@Yahoo.com>

* 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