[
https://issues.apache.org/jira/browse/DERBY-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503706
]
Dag H. Wanvik commented on DERBY-2786:
--------------------------------------
I had a look at the client code; it does not handle CallableStatement#getXXX()
prior to executing the procedure INOUT parameters:
E.g.
int getIntX(int parameterIndex) throws SqlException {
super.checkForClosedStatement();
checkGetterPreconditions(parameterIndex);
setWasNull(parameterIndex);
** return wasNullX() ? 0 : singletonRowData_.getInt(parameterIndex);
}
The setWasNull throws if the procedure has not been executed yet.
Embedded handles this. It is not obvious from the Javadoc
that this is a requirement:
(quote from CallableStatement):
"The type of all OUT parameters must be registered prior to executing the
stored procedure;
their values are retrieved after execution via the get methods provided here."
I found no verbiage discussing whether it is legal to access an INOUT parameter
prior to execution.
BTW, in my small repro, I got an exception on the client (not wrong value as
mention in thread; don't know why;
looking at the code it seems there should be an exception, but maybe the some
flag is not cleared on
re-execution.
Output from my repro:
* Testing with org.apache.derby.jdbc.ClientDriver
XJ088: java.sql.SQLException: Invalid operation: wasNull() called with no data
retrieved.
java.sql.SQLException: Invalid operation: wasNull() called with no data
retrieved.
at
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
at
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:362)
at
org.apache.derby.client.am.CallableStatement.getInt(CallableStatement.java:322)
at derby2786.Main.doStuff(Main.java:126)
at derby2786.Main.doBothDrivers(Main.java:192)
at derby2786.Main.main(Main.java:211)
Caused by: org.apache.derby.client.am.SqlException: Invalid operation:
wasNull() called with no data retrieved.
at
org.apache.derby.client.am.CallableStatement.wasNullX(CallableStatement.java:226)
at
org.apache.derby.client.am.CallableStatement.getIntX(CallableStatement.java:331)
at
org.apache.derby.client.am.CallableStatement.getInt(CallableStatement.java:313)
... 3 more
* Testing with org.apache.derby.jdbc.EmbeddedDriver
DUMMYINT alias before returned 6
DUMMYINT alias after returned 22222
> Behaviour of inout parameters in Embedded and Network client is different if
> parameters are set but the CallableStatment is not executed.
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-2786
> URL: https://issues.apache.org/jira/browse/DERBY-2786
> Project: Derby
> Issue Type: Bug
> Components: Network Client
> Affects Versions: 10.3.0.0
> Environment: Operating Systems: Fedora Core release 6
> Reporter: Ramin Moazeni
>
> The behavior of embedded and network client is different in for inout
> parameters if parameters are set but the CallableStatment is not executed.
> For detailed description of this issue on derby-dev, refer to
> http://www.nabble.com/Regarding-DERBY-2658%3A-Converting-jdbcapi-parameterMetaDataJdbc30.java-to-JUnit-tf3882490.html#a11003923
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.