This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Registering IN OUT parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Registering IN OUT parameter" Watch "Registering IN OUT parameter" New topic
Author

Registering IN OUT parameter

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hi All -

I searched couple of books and searched on net but couldn't find the syntax I'm looking for. Hope you guys can help. I'm calling a oracle proc in my java app. The proc returns a cursor. Can you please guide to how to define the IN OUT parameter. Thanks






[ January 25, 2006: Message edited by: Dilip kumar ]
Evgeniy Bulanov
Greenhorn

Joined: Dec 19, 2005
Posts: 23
In order to get the results from a stored procedure call, you must register any OUT or IN OUT
parameters before executing the CallableStatement. To do this, call the
CallableStatement object's registerOutParameter( ) method, passing it the position of
the placeholder character in the callable-statement string starting at 1 and moving from left to
right, just as you do for the other accessor methods, and a java.sql.Types constant to specify
the SQL data type that will be returned. There are two applicable signatures for the
registerOutParameter( ) method. For VARCHAR2 and DATE parameters, use the
following signature:
registerOutParameter(
int parameterIndex,
int sqlType)
throws SQLException

(Java Programming with Oracle JDBC ISBN: 0-596-00088-x, 496 pages)


Computers are like air conditioners - They stop working properly when you open Windows
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Thanks for the response.

Looks like still something is wrong in my code. I'm getting error message
PLS-00306: wrong number or types of arguments in call to getValues

Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
I notice that your OUT param 'TYPE lineCurs IS REF CURSOR RETURN lineItemRec' is of type REF CURSOR.
For Oracle, the param for registerOutParameter() is oracle.jdbc.driver.OracleTypes.CURSOR.
Check the driver JAR file for the apt type code.
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Thanks much.

It worked when I used
csmt.registerOutParameter(14, OracleTypes.CURSOR);
 
 
subject: Registering IN OUT parameter
 
Similar Threads
How to read object collection as an out parameter of stored procedure(Oracle)?
How to return a collection of records from a stored procedure?
Question about cursor as stored procedure parameter
Returning Cursor from Stored Procedure
Error :java.sql.SQLException: Invalid column index