Received: from hobbit.3logic.net (hobbit.3logic.net [195.38.16.2]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAKFX5m29519 for ; Tue, 20 Nov 2001 10:33:06 -0500 (EST) (envelope-from andriy.pyrozhenko@vanjaonline.com) Received: (qmail 27535 invoked from network); 20 Nov 2001 17:33:08 +0200 Received: (qmail: 1.03); 20 Nov 2001 15:33:08 -0000 Received: from onetim.3logic.net (HELO mail.vanjaonline.com) (195.38.17.73) by hobbit.3logic.net with SMTP; 20 Nov 2001 17:33:06 +0200 Received: from PYROZHENKO ([192.168.1.10]) by mail.vanjaonline.com (WinRoute Pro 4.1.29) with SMTP; Tue, 20 Nov 2001 17:31:46 +0200 Date: Tue, 20 Nov 2001 17:31:37 +0200 From: Andriy Pyrozhenko X-Mailer: The Bat! (v1.53bis) Reply-To: Andriy Pyrozhenko X-Priority: 3 (Normal) Message-ID: <6331217468.20011120173137@vanjaonline.com> To: pgsql-sql@postgresql.org Subject: Re: Rule In-Reply-To: <29543.1006269869@sss.pgh.pa.us> References: <7524444939.20011120153845@vanjaonline.com> <29543.1006269869@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200111/294 X-Sequence-Number: 5676 Hello Tom, Tuesday, November 20, 2001, 5:24:29 PM, you wrote: TL> Andriy Pyrozhenko writes: >> CREATE RULE del_jobs_del_activity AS ON DELETE TO jobs DO DELETE FROM activities WHERE job_id = OLD.job_id; >> DELETE FROM jobs WHERE job_id IN (SELECT DISTINCT job_id FROM >> activities WHERE load_no = 123) >> This query does not delete the record from jobs but delete the >> record by rule. TL> I think you're going to need to use a trigger, instead. The TL> rule-generated query runs first, and then by the time you get to the TL> actual DELETE FROM jobs, the SELECT DISTINCT subquery doesn't find any TL> rows ... TL> regards, tom lane How can I do it. I use PostgreSQL 7.1.3 Best regards, Andriy mailto:andriy.pyrozhenko@vanjaonline.com