pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
problems with currval and rollback
2+ messages / 2 participants
[nested] [flat]

* problems with currval and rollback
@ 2005-12-23 01:37  Assad Jarrahian <jarraa@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Assad Jarrahian @ 2005-12-23 01:37 UTC (permalink / raw)
  To: pgsql-jdbc

Hi all,
  So I started to make some changes with my jdbc 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. It should rollback, but it does not. What gives?

I ran the insert-currval combo  from psql and it worked.
What gives?


Any help would be appreciated.

-assad



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: problems with currval and rollback
@ 2005-12-23 03:12  Oliver Jowett <oliver@opencloud.com>
  parent: Assad Jarrahian <jarraa@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2005-12-23 03:12 UTC (permalink / raw)
  To: Assad Jarrahian <jarraa@gmail.com>; +Cc: pgsql-jdbc

Assad Jarrahian wrote:
> Hi all,
>   So I started to make some changes with my jdbc code here and there
> (nothing to do with the relevant lines) and suddenly currval and
> rollback don't work.

We really need a selfcontained testcase, especially since it sounds like 
the problem depends on the exact logic you're executing, not just the 
update/currval bit.

-O



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-12-23 03:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-23 01:37 problems with currval and rollback Assad Jarrahian <jarraa@gmail.com>
2005-12-23 03:12 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox