ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <dhsc...@cstone.dhs.state.il.us>
Subject Re: Problem with DB2, IBATIS and IBM Updatable Cursors
Date Thu, 28 Jul 2005 12:49:43 GMT
Yes - a stored proc is what you want if you really need to do this. 
However...

I assume your example is simplified a bit for the list.  The example as
it is will only update one row - the first row from the cursor (an
indeterminate row).  If you really mean to update all rows in the table,
you could do this:

   UPDATE T1 set cod_number = cod_number + 1

It's one SQL statement versus many (hundreds, thousands?)

The UPDATE statement has a very rich syntax.  There's probably a way to
do what you want in one statement - then it would work with iBATIS!

Jeff Butler



>>> larry.meadors@gmail.com 07/28/05 7:20 AM >>>
With a stored procedure, it would be a snap.

Larry


On 7/28/05, Juanpe <jupecal@gmail.com> wrote:
> 
> Hello!
> 
> I have a problem with IBM Updatable Cursors (DB2), I need to
associate
> a cursor to a select sentence, to use it in another sentence (an
> update sentence). The code would be the following one (SELECT FOR
> UPDATE) in Java:
> 
> mCon.setAutoCommit(false);
> stmt = mCon.createStatement();
> stmt.setCursorName("UPDATABLESTATEMENT");
> stmt2 = mCon.createStatement();
> SQL = "SELECT * FROM T1 FOR UPDATE OF cod_number";
> rs = stmt.executeQuery(SQL);
> rs.next();
> SQL2 = "UPDATE T1 set cod_number = cod_number + 1 WHERE CURRENT OF
> UPDATABLESTATEMENT";
> stmt2.executeUpdate(SQL2);
> stmt.close();
> stmt2.close();
> mCon.commit();
> mCon.close();
> 
> Is possible to do this using Ibatis?
> 
> Thanks in advance.
> 
> JP
>

Mime
View raw message