permaculture playing cards
The moose likes JDBC and Relational Databases and the fly likes how to access an IN OUT parameter ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to access an IN OUT parameter ?" Watch "how to access an IN OUT parameter ?" New topic

how to access an IN OUT parameter ?

Dilip Maddi

Joined: Nov 17, 2003
Posts: 3
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);
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

Joined: Sep 03, 2003
Posts: 399
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.
I agree. Here's the link:
subject: how to access an IN OUT parameter ?
It's not a secret anymore!