Rules & sequences

Поиск
Список
Период
Сортировка
От Tamsin
Тема Rules & sequences
Дата
Msg-id 00a801bffacc$751a6640$0100a8c0@tamsin
обсуждение исходный текст
Ответы Re: Rules & sequences  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi, I wonder if anyone can help?

I'm working on an audit trail, and trying to do it with rules.  update &
delete are ok, I'm having a problem with my insert rule -

create rule address_ins as on insert to address DO
insert into address_hist values (new.*,current_timestamp,'insert');

The problem is, my address table has default nextval('address_id_seq') as
the default for the Primary key.  When I insert into the address table, the
rule seems to take the nextval of the sequence for the audit table, and then
the actual insert into the address table takes another nextval, so the
record in the audit table has a different ID to the main table, which isn;t
really very good for auditing!  Is there anything I can do about this, or
will I have to do an after insert trigger instead?

Thanks,
Tamsin


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

Предыдущее
От: "Chris Knight"
Дата:
Сообщение: RE: pg_dump not working
Следующее
От: Janne Blomqvist
Дата:
Сообщение: VS: Backup/dump of huge tables and performance