Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f22DKrx06279 for ; Fri, 2 Mar 2001 08:20:53 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from mjtsa.com (mjtgtw2.mjt.ch [194.209.241.21]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1RFhnx67507 for ; Tue, 27 Feb 2001 10:43:49 -0500 (EST) (envelope-from bc@mjtsa.com) Received: (from bc@localhost) by mjtsa.com (8.9.2/dc) id QAA02463 for pgsql-sql@postgresql.org; Tue, 27 Feb 2001 16:43:25 GMT Date: Tue, 27 Feb 2001 16:43:25 GMT From: Blaise Carrupt Message-Id: <200102271643.QAA02463@mjtsa.com> To: pgsql-sql@postgresql.org Subject: Help creating rules/triggers/functions Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-MD5: uPc97H3Yv8NzqA88XIZM4Q== X-Archive-Number: 200103/17 X-Sequence-Number: 1659 Hi all ! I use PostgreSQL 7.0.2 on a HP-UX system. I would like to create a simple function and a simple trigger (or rule) that deny a delete from a table if the row is referenced in another table. I though it should look like this (from my Ingres experience... :) : create function A_del(int4 i_id) BEGIN SELECT id FROM b where a_id = :i_id; if rowcount > 0 then RAISE EXCEPTION "not allowed !" end if; END create trigger before delete from A for each row execute procedure A_del(old.id) But it seems to be much more complicated with Postgres (create a C function using CurrentTriggerData,...). May I have missed something or is it really much more complicated ? Thanks for help. _____________ B. Carrupt