pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
preventing deletion of a row
3+ messages / 2 participants
[nested] [flat]

* preventing deletion of a row
@ 2005-06-07 05:29  Kenneth Gonsalves <lawgon@thenilgiris.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Kenneth Gonsalves @ 2005-06-07 05:29 UTC (permalink / raw)
  To: pgsql-sql

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
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: preventing deletion of a row
@ 2005-06-07 05:59  Nick Johnson <arachnid@notdot.net>
  parent: Kenneth Gonsalves <lawgon@thenilgiris.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Nick Johnson @ 2005-06-07 05:59 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: preventing deletion of a row
@ 2005-06-07 06:43  Kenneth Gonsalves <lawgon@thenilgiris.com>
  parent: Nick Johnson <arachnid@notdot.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Kenneth Gonsalves @ 2005-06-07 06:43 UTC (permalink / raw)
  To: Nick Johnson <arachnid@notdot.net>; +Cc: pgsql-sql

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
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-06-07 06:43 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-07 05:29 preventing deletion of a row Kenneth Gonsalves <lawgon@thenilgiris.com>
2005-06-07 05:59 ` Nick Johnson <arachnid@notdot.net>
2005-06-07 06:43   ` Kenneth Gonsalves <lawgon@thenilgiris.com>

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