Received: from hobbit.3logic.net (hobbit.3logic.net [195.38.16.2]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAN7GTm05728 for ; Fri, 23 Nov 2001 02:16:29 -0500 (EST) (envelope-from andriy.pyrozhenko@vanjaonline.com) Received: (qmail 8010 invoked from network); 23 Nov 2001 09:16:20 +0200 Received: (qmail: 1.03); 23 Nov 2001 07:16:20 -0000 Received: from onetim.3logic.net (HELO mail.vanjaonline.com) (195.38.17.73) by hobbit.3logic.net with SMTP; 23 Nov 2001 09:16:19 +0200 Received: from PYROZHENKO ([192.168.1.10]) by mail.vanjaonline.com (WinRoute Pro 4.1.29) with SMTP; Fri, 23 Nov 2001 09:14:55 +0200 Date: Fri, 23 Nov 2001 09:14:54 +0200 From: Andriy Pyrozhenko X-Mailer: The Bat! (v1.53bis) Reply-To: Andriy Pyrozhenko X-Priority: 3 (Normal) Message-ID: <1721749786.20011123091454@vanjaonline.com> To: pgsql-sql@postgresql.org Subject: Re: Question In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200111/331 X-Sequence-Number: 5713 Hello Christopher, I don't need delete record from jobs when I delete record from activity. But I need delete record from activity when I delete the record from jobs and I need to find this job_id in activities table! What must I do? CKL> Question: Why don't you just set up a foreign key that will achieve exactly CKL> the same thing without using RULEs? CKL> ie. ALTER TABLE activities ADD FOREIGN KEY (job_id) REFERENCES jobs(job_id) CKL> ON DELETE CASCADE; CKL> Chris >> I have the rule for table >> CREATE RULE del_jobs_del_activity AS ON DELETE TO jobs DO >> DELETE FROM activities WHERE job_id = OLD.job_id; >> >> When i call: >> DELETE FROM jobs WHERE job_id IN (SELECT DISTINCT job_id FROM >> activities WHERE load_no = OLD.load_no) >> This query does not delete the record from jobs but delete the >> record by rule. Best regards, Andriy mailto:andriy.pyrozhenko@vanjaonline.com