Обсуждение: sequences and rollback

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

sequences and rollback

От
Rick Roman
Дата:
Do I understand correctly that you cannot roll back sequences?

JDBC example:

      connect();
      db.setAutoCommit(false);
      Statement stmt=db.createStatement();
      stmt.executeQuery("select nextval('test_seq')");
     ... other table updates ...
      stmt.close();
      db.rollback();
      db.close();

In this example, the sequence does not roll back. .. other table updates
... do roll back.

Re: sequences and rollback

От
Michael Fuhr
Дата:
On Thu, Mar 31, 2005 at 11:18:19AM -0800, Rick Roman wrote:
>
> Do I understand correctly that you cannot roll back sequences?

Correct.  This is mentioned in the documentation and in the FAQ.

http://www.postgresql.org/docs/8.0/interactive/functions-sequence.html
http://www.postgresql.org/docs/faqs.FAQ.html#4.11.4

You can manually set a sequence's value with setval() or ALTER
SEQUENCE, but that's not the same as rolling back values that you
didn't use.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/