Обсуждение: preventing deletion of a row

Поиск
Список
Период
Сортировка

preventing deletion of a row

От
Kenneth Gonsalves
Дата:
hi
i have a table of the type:

id serial unique,
name varchar(50),
fixed boolean default FALSE

if the value of 'fixed' is TRUE, then this row cannot be deleted. How
do i enforce this condition?
--
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.sourceforge.net
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Re: preventing deletion of a row

От
Nick Johnson
Дата:
Kenneth Gonsalves wrote:

>hi
>i have a table of the type:
>
>id serial unique,
>name varchar(50),
>fixed boolean default FALSE
>
>if the value of 'fixed' is TRUE, then this row cannot be deleted. How 
>do i enforce this condition?
>  
>
Try this:
CREATE RULE tablename_delete AS ON DELETE TO tablename WHERE OLD.fixed = 
TRUE DO INSTEAD NOTHING;

-Nick Johnson


Re: preventing deletion of a row

От
Kenneth Gonsalves
Дата:
On Tuesday 07 Jun 2005 11:29 am, Nick Johnson wrote:
> >if the value of 'fixed' is TRUE, then this row cannot be deleted.
> > How do i enforce this condition?
> >  
>
> Try this:
> CREATE RULE tablename_delete AS ON DELETE TO tablename WHERE
> OLD.fixed = TRUE DO INSTEAD NOTHING;

cool - thanks

--
regards
kg

http://www.livejournal.com/users/lawgon
tally ho! http://avsap.sourceforge.net
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!