X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id EF78230EA73 for ; Fri, 13 Jun 2003 13:50:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 35229-05 for ; Fri, 13 Jun 2003 10:50:11 -0300 (ADT) Received: from web20805.mail.yahoo.com (web20805.mail.yahoo.com [216.136.226.194]) by svr1.postgresql.org (Postfix) with SMTP id 7C2E330D18F for ; Fri, 13 Jun 2003 10:50:10 -0300 (ADT) Message-ID: <20030613135010.71562.qmail@web20805.mail.yahoo.com> Received: from [208.13.35.65] by web20805.mail.yahoo.com via HTTP; Fri, 13 Jun 2003 06:50:10 PDT Date: Fri, 13 Jun 2003 06:50:10 -0700 (PDT) From: Jeff Eckermann Subject: Re: trigger : emulate "instead of" with before ? To: Albrecht Berger , pgsql In-Reply-To: <046801c331a2$0c483e70$a07ba8c0@wxp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200306/122 X-Sequence-Number: 13880 I believe that if you return NULL from the trigger function, the delete will not actually be done. You could set the value of the delete flag by reference to OLD.fieldname. I have not actually done this myself, so caveat emptor. --- Albrecht Berger wrote: > Hello, > I need a trigger which is updating a delete flag of > a row instead of > deleting it physically. > > How do I implement a trigger which doesn't execute a > delete without raising > an exception > in plsql ? > > CREATE TRIGGER trigger1 BEFORE DELETE ON table1 > FOR EACH ROW EXECUTE PROCEDURE setDeleteFlag (); > > If I use > RAISE EXCEPTION "..." > the delete statement isn't executed, but I think the > transaction is rolled > back too, am I right ? > > So what is the best way to implement something > (Oracle like) like that : > CREATE TRIGGER trigger1 INSTEAD OF DELETE ON table1 > FOR EACH ROW EXECUTE PROCEDURE setDeleteFlag (); > > thx > > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com