From: Blaise Carrupt <bc@mjtsa.com>
To: pgsql-sql@postgresql.org
Subject: Help creating rules/triggers/functions
Date: Tue, 27 Feb 2001 16:43:25 GMT
Message-ID: <200102271643.QAA02463@mjtsa.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: bc@mjtsa.com
Subject: Re: Help creating rules/triggers/functions
In-Reply-To: <200102271643.QAA02463@mjtsa.com>
References: <200102271643.QAA02463@mjtsa.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox