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

Поиск
Список
Период
Сортировка
От Thomas Markus
Тема Re: How to make a non-removable row in a table?
Дата
Msg-id 4EEEEFBF.2020703@proventis.net
обсуждение исходный текст
Ответ на Re: How to make a non-removable row in a table?  (Капралов Александр<alnkapa@gmail.com>)
Список 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;
>


В списке pgsql-general по дате отправления:

Предыдущее
От: Капралов Александр
Дата:
Сообщение: Re: How to make a non-removable row in a table?
Следующее
От: Emanuel Calvo
Дата:
Сообщение: Re: [pgeu-general] REMINDER: FOSDEM 2012 - PostgreSQL Devroom: Call for Speakers