Re: DO INSTEAD and conditional rules

Поиск
Список
Период
Сортировка
От David Wheeler
Тема Re: DO INSTEAD and conditional rules
Дата
Msg-id 79e6a42116d6cd9a74bb021041d3953a@kineticode.com
обсуждение исходный текст
Ответ на Re: DO INSTEAD and conditional rules  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Apr 26, 2005, at 2:58 PM, Tom Lane wrote:

> ... which indeed can be a feature, not a bug, depending on what you're
> doing ...

Absolutely. An INSERT rule I have looks like this:

CREATE RULE insert_one AS
ON INSERT TO one WHERE NEW.id IS NULL
DO INSTEAD (  INSERT INTO _simple (id, guid, state, name, description)  VALUES (NEXTVAL('seq_kinetic'), NEW.guid,
NEW.state,NEW.name, 
 
NEW.description);
  INSERT INTO simple_one (id, bool)  VALUES (CURRVAL('seq_kinetic'), NEW.bool);
);

The call to NEXTVAL() in the first statement sets up a value I use in 
the second via CURRLVA().

Cheers,

David



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: DO INSTEAD and conditional rules
Следующее
От: Greg Stark
Дата:
Сообщение: Re: [PERFORM] Bad n_distinct estimation; hacks suggested?