Thread: preventing deletion of a row
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 ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
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
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 ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!