Search Postgresql Archives

Re: How to make a non-removable row in a table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

simple violate a contraint.

my test:

drop table if exists x;
create temp table x (
id int not null primary key,
name text
);

-- check against not null
create rule test_rule as on delete to x where old.id=1 do instead update x set id=null;
insert into x values( 1,'a'),(2,'b');
select * from x;

-- fails
delete from x;

delete from x where id!=1;
select * from x;



regards
Thomas


Am 19.12.2011 08:16, schrieb Капралов Александр:
I found a simple solution, but i don't know how to add raises an exception here.

create rule protect_profile_id0_update as  on update to web.profile
where old.id = 0  do instead nothing;
create rule protect_profile_id0_delete as  on delete to web.profile
where old.id = 0  do instead nothing;



--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux