Using Procedures with INOUT Parameters in JDBC

Hi All

It is very easy in Java to pass and get the data for same procedure parameter(using the same parameter as IN and OUT type). All you need to do is to define the parameter with IN and OUT keywords in Stored procedure.
PROCEDURE my_proc_name (
in_type        IN      VARCHAR,
in_type_second   IN OUT   VARCHAR,   — This input parameter will now act like an Output parameter as well

Now in the Java class method, All you have to do is to just to set the input and output parameters. e.g.

cstmt = this.getConnection().prepareCall(“{call pkg.my_proc_name(?,?}”);
cstmt.setString(1, “XYZ”);
cstmt.setString(2, “INPUT”); // Assigning the input
cstmt.registerOutParameter(2, OracleTypes.VARCHAR); // registering the output for same parameter.


R Vashi

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.