| From: | Thomas Markus <t(dot)markus(at)proventis(dot)net> |
|---|---|
| To: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: How to make a non-removable row in a table? |
| Date: | 2011-12-19 08:03:11 |
| Message-ID: | 4EEEEFBF.2020703@proventis.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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;
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Emanuel Calvo | 2011-12-19 09:02:11 | Re: REMINDER: FOSDEM 2012 - PostgreSQL Devroom: Call for Speakers |
| Previous Message | Капралов Александр | 2011-12-19 07:16:06 | Re: How to make a non-removable row in a table? |