Обсуждение: Antw: Rollback & Nextval fails

Поиск
Список
Период
Сортировка

Antw: Rollback & Nextval fails

От
"Gerhard Dieringer"
Дата:
Fredrik Eriksson wrote:

> I have been trying the following SQL code :

> BEGIN;
> INSERT INTO table VALUES ( NEXTVAL('serial'), 'Data' );
> ROLLBACK;

> And the insert function is rolled back but the serial sequence isn't. Hav I
> misunderstood the functionality of rollback or is this a bug? Is there
> someway to get the functionality that rollsback everything?

It's not a bug but a feature. 
Sequence numbers exist to create unique entity-id-number with (usually) no external meaning, so 
1.) there is no need to roll them back
2.) the system would have to keep a list, what sequence number were rolled back.

Gerhard