problems with currval and rollback

Поиск
Список
Период
Сортировка
От Assad Jarrahian
Тема problems with currval and rollback
Дата
Msg-id 4bd3e1480512221625q71115ffer4e5b0e9b10f84b17@mail.gmail.com
обсуждение исходный текст
Ответы Re: problems with currval and rollback  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: problems with currval and rollback  (Pandurangan R S <pandurangan.r.s@gmail.com>)
Re: problems with currval and rollback  (Edward Macnaghten <eddy@edlsystems.com>)
Список pgsql-general
Hi all,
   So I started to make some changes with my code here and there
(nothing to do with the relevant lines) and suddenly currval and
rollback don't work.

          try{
            db.setAutoCommit(false);
            addLM.setInt(1, lm.getOrigin());
                           .......
                     addLM.executeUpdate();
                     sql = db.createStatement();
                      ResultSet result = sql.executeQuery("SELECT
currval('lm_id_seq');");
            if (result. next()){
                db.commit();
                db.setAutoCommit(true);
                         else{
                db.rollback(); //reverse all changes
                db.setAutoCommit(true);
                       }
        catch(SQLException ex){
            try {
                db.rollback();
                db.setAutoCommit(true);
            } catch (SQLException e) {
                throw e;
                       }
            throw ex;
       }

What happens is that the it inserts a db, but cannot get a value back
using currval  (ERROR: ERROR: currval of sequence "lm_id_seq" is not
yet defined in this session 55000  ) , yet the db gets the addlm
inserted.


Shouldn't it rollback?
Furthermore, why would currval suddenly stop working?

Much thanks for your feedback in advance.

-assad

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

Предыдущее
От: Trent Shipley
Дата:
Сообщение: Re: Inheritance Algebra
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: problems with currval and rollback