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

2012-01-29 Thread Jasen Betts
On 2011-12-19, Капралов Александр alnk...@gmail.com wrote: Hi all. How to make a non-removable row in a table? reference it from another table. -- ⚂⚃ 100% natural -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

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

2011-12-19 Thread Thomas Markus
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 *

[GENERAL] How to make a non-removable row in a table?

2011-12-18 Thread Капралов Александр
Hi all. How to make a non-removable row in a table? In my case, I should not accidentally delete a row with id = 0. CREATE TABLE profile ( id integer NOT NULL, name character varying(265) NOT NULL ); CREATE SEQUENCE profile_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE

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

2011-12-18 Thread Thomas Markus
Hi, create a delete trigger that raises an exception Thomas Am 19.12.2011 07:43, schrieb Капралов Александр: Hi all. How to make a non-removable row in a table? In my case, I should not accidentally delete a row with id = 0. CREATE TABLE profile ( id integer NOT NULL, name

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

2011-12-18 Thread Капралов Александр
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;