Help creating rules/triggers/functions

Поиск
Список
Период
Сортировка
От Blaise Carrupt
Тема Help creating rules/triggers/functions
Дата
Msg-id 200102271643.QAA02463@mjtsa.com
обсуждение исходный текст
Ответы Re: Help creating rules/triggers/functions  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: Help creating rules/triggers/functions  (Jan Wieck <janwieck@Yahoo.com>)
Список pgsql-sql
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 thenRAISE 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] why the DB file size does not reduce when 'delete' the data in DB?
Следующее
От: Andrew Perrin
Дата:
Сообщение: Re: create function w/indeterminate number of args?