Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access an IN OUT parameter ?

 
Dilip Maddi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through a CallableStatment i had invoked a database procedure accepting a parameter of IN OUT type.
CallableStatement cs = conn.prepareCall("{call PROC(?1)}");
I had passes an BigDecimal for an IN OUT parameter of number type

BigDecimal bd = new BigDecimal(20);
cs.setBigDecimal(1,bd);
cs.execute();
System.out.println(" update value "+bd);

After executing the callable statement I had printed the big-decimal value
Sadly it had printed me the old value instead of new value.


Can anyone of you help with an example ?
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that all you need to do is add: cs.registerOutParameter(1, java.sql.Types.BIGINT); (or whatever java type is appropriate for your database) before you do the "cs.execute()". You still need the cs.setBigDecimal() call. In other words you do both since it's both an input and output parameter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic