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 AB5A930EAE0 for ; Fri, 13 Jun 2003 13:10:11 +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 31855-02 for ; Fri, 13 Jun 2003 10:10:01 -0300 (ADT) Received: from ms-smtp-03.tampabay.rr.com (ms-smtp-03.tampabay.rr.com [65.32.1.41]) by svr1.postgresql.org (Postfix) with ESMTP id E216A30EACB for ; Fri, 13 Jun 2003 10:10:00 -0300 (ADT) Received: from mattspc (169-52.34-65.tampabay.rr.com [65.34.52.169]) by ms-smtp-03.tampabay.rr.com (8.12.5/8.12.5) with ESMTP id h5DD9v4U028649; Fri, 13 Jun 2003 09:09:58 -0400 (EDT) From: "Matthew Nuzum" To: "'Albrecht Berger'" , "'pgsql'" Subject: Re: trigger : emulate "instead of" with before ? Date: Fri, 13 Jun 2003 09:09:52 -0400 Organization: Bearfruit.org Message-ID: <001501c331ad$14207300$a322fea9@mattspc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <046801c331a2$0c483e70$a07ba8c0@wxp> Importance: Normal X-Archive-Number: 200306/121 X-Sequence-Number: 13879 I'm not a postgres expert, and I certainly don't know the details of your situation, but it seems to me you may want to use a rule instead of a trigger. Then, you can intercept the delete query and simply re-write it to be an update query that sets your deleted flag. -- Matthew Nuzum www.bearfruit.org cobalt@bearfruit.org =20 > -----Original Message----- > From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql- > owner@postgresql.org] On Behalf Of Albrecht Berger > Sent: Friday, June 13, 2003 7:51 AM > To: pgsql > Subject: [SQL] trigger : emulate "instead of" with before ? >=20 > Hello, > I need a trigger which is updating a delete flag of a row instead of > deleting it physically. >=20 > How do I implement a trigger which doesn't execute a delete without > raising > an exception > in plsql ? >=20 > CREATE TRIGGER trigger1 BEFORE DELETE ON table1 > FOR EACH ROW EXECUTE PROCEDURE setDeleteFlag (); >=20 > If I use > RAISE EXCEPTION "..." > the delete statement isn't executed, but I think the transaction is rolled > back too, am I right ? >=20 > 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 (); >=20 > thx >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? >=20 > http://www.postgresql.org/docs/faqs/FAQ.html