JDBC - calling a function with a OUT parameter
Posted in 2000
I created a function in the Informix Dynamic Server 9.21 server as:
CREATE FUNCTION subscribe_email_address(email_address_p varchar(255),
listname_p varchar(80), OUT effected_p int)
RETURNING int..
..
END FUNCTION
Executing the function using JDBC gives me the following error :
java.sql.SQLException: Argument must be a Statement Local Variable for
an OUT parameter.
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at java.sql.SQLException.<init>(SQLException.java:43)
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java)
at com.informix.jdbc.IfxSqli.errorDone(IfxSqli.java)
at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java)
at com.informix.jdbc.IfxSqli.receiveMessage(Compiled Code)
at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java)
at com.informix.jdbc.IfxResultSet.executePrepare
(IfxResultSet.java)
at com.informix.jdbc.IfxPreparedStatement.<init>
(IfxPreparedStatement.java)
at com.informix.jdbc.IfxCallableStatement.<init>
(IfxCallableStatement.java)
at com.informix.jdbc.IfxSqliConnect.prepareCall
(IfxSqliConnect.java)
at DbPing.main(DbPing.java:453)
Can anyone shed some light on my problem?
--------------Excerpt of the code -------------------------------
String command = "{ ? = call unsubscribe_email_address
(? , ?, ?)} ";
System.out.println("prepareCall...preparing");
CallableStatement cstmt_t = null;
cstmt_t = tcon.prepareCall(command);
System.out.println("prepareCall (" + command + ")...okay");
System.out.println("");
System.out.println("");
System.out.println("Warnings on CallableStatement
object: ");
System.out.println("setString1");
cstmt_t.setString(1, "emailAddress@yahoo.com");
System.out.println("setString2");
cstmt_t.setString(2, "listname");
System.out.println("setInt3");
cstmt_t.setInt(3, 1);
cstmt_t.registerOutParameter(3, java.sql.Types.INTEGER);
ResultSet rs = cstmt_t.executeQuery();
Sent via Deja.com
http://www.deja.com/