Product: | JDBC DBConnectivity Product for IBM Db2 (HiT JDBC/DB2) |
Version: | All |
ID: | 1202 |
Summary: | How to use an outparameter with a stored procedure with a stored procedure that returns char/varchar type |
IBM Db2 handles output parameters internally and its size needs to be specified when calling a stored procedure that returns char/varchar data types. For example, the following stored procedure has one input parameter of type INT and one output parameter of type VARCHAR:
CallableStatement cs = conn.prepareCall("{call mysp(?,?)}");
cs.setString(1,1234);
cs.registerOutParameter(2, Types.VARCHAR);
cs.setString(2, new String(new byte[1000])); // dummy to indicate size
cs.execute();