MySQL Forums
Forum List  »  Stored Procedures

INOUT parameter problem.
Posted by: R A
Date: December 02, 2005 10:13PM

Hello, I'm trying to run a stored procedure in MySQL 5.0 through the use of Java. Here's what I have:

Part of my Java code (which is taken from the MySQL Connector/J documentation):


CallableStatement cStmt = conn.prepareCall("{call demoSp(?, ?)}");
cStmt.registerOutParameter("inOutParam", Types.INTEGER);
cStmt.setString(1, "hello");
cStmt.setInt("inOutParam", 4);
cStmt.execute();
System.out.println(cStmt.getInt("inOutParam"));


The stored procedure (which has been taken directly from the MySQL Connector/J documentation, PDF format, Page 4)

CREATE PROCEDURE demoSp(IN inputParam VARCHAR(255), INOUT inOutParam INT)
BEGIN
DECLARE z INT;
SET z = inOutParam + 1;
SET inOutParam = z;
SELECT inputParam;
SELECT CONCAT('zyxw', inputParam);
END


I have tested the query in MySQL and the stored procedure does work correctly. The Java code successfuly runs the stored procedure, but the INOUT parameter always returns as 1. This behaviour indicates that when the stored procedure runs, inOutParam is set to 0, regardless of what value it is given in the Java code. Therefore, is the INOUT parameter fully supported?

Thanks in advance for a response.

Options: ReplyQuote


Subject
Views
Written By
Posted
INOUT parameter problem.
6442
R A
December 02, 2005 10:13PM
2476
December 03, 2005 07:49AM
4135
R A
December 03, 2005 03:09PM
2246
jan
December 04, 2005 02:15PM
2148
December 04, 2005 08:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.