X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2710BD1B17C for ; Wed, 9 Jun 2004 22:45:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36747-09 for ; Thu, 10 Jun 2004 01:45:13 +0000 (GMT) Received: from smtp015.mail.yahoo.com (smtp015.mail.yahoo.com [216.136.173.59]) by svr1.postgresql.org (Postfix) with SMTP id 4644FD1B26C for ; Wed, 9 Jun 2004 22:45:08 -0300 (ADT) Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with login) by smtp015.mail.yahoo.com with SMTP; 10 Jun 2004 01:45:12 -0000 Received: from Yahoo.com (pcp01341166pcs.wilog301.pa.comcast.net [68.80.245.191]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i5A1jEs04103; Wed, 9 Jun 2004 21:45:14 -0400 Message-ID: <40C7BD04.1040105@Yahoo.com> Date: Wed, 09 Jun 2004 21:44:36 -0400 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: miker@purplefrog.com Cc: pgsql-sql@postgresql.org Subject: Re: Trigger problem References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/76 X-Sequence-Number: 18021 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 #