Re: INSERT RULE doesn't allow OLD, so how does one work with serial datatypes?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: INSERT RULE doesn't allow OLD, so how does one work with serial datatypes?
Дата
Msg-id 20060513211810.GM12955@svana.org
обсуждение исходный текст
Ответ на INSERT RULE doesn't allow OLD, so how does one work with serial datatypes?  ("Karen Hill" <karen_hill22@yahoo.com>)
Список pgsql-general
On Sat, May 13, 2006 at 02:11:14PM -0700, Karen Hill wrote:
> I'm having a bit of mystery in solving a postgresql puzzle.  I have a
> table that when it gets inserted or updated or deleted it is logged
> into a log table.  The log table contains who (current_user) did the
> insert/update/delete the CURRENT_TIMESTAMP.  Everything works great
> except the INSERT because I cannot use OLD and NEW increments the
> serial twice!

You cannot use OLD because there is no old row. And rules are like
macros, so the nextval() gets evaluated twice.

You probably want a trigger...
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: "Karen Hill"
Дата:
Сообщение: INSERT RULE doesn't allow OLD, so how does one work with serial datatypes?
Следующее
От: Jerry LeVan
Дата:
Сообщение: Mac Problem with Tunneling...