Calling SQL functions using CallableStatement with registerOutParameter(...) produces the following error:
Invalid argument in JDBC call: Not OUT or INOUT mode: 1 for parameter: 1
See also: https://sourceforge.net/projects/hsqldb/forums/forum/73673/topic/3363850
Steps to reproduce:
1. Define function:
CREATE FUNCTION duplicate(IN num INTEGER)
RETURNS INTEGER
RETURN num * 2;
;
2. Call function
CallableStatement cs = connection.prepareCall("{ ? = call duplicate(?) }");
cs.registerOutParameter(1, Types.INTEGER, 0);
cs.setInt(2, 5);
cs.execute();
Maven project with failing unit test
Currently an HSQLDB FUNCTION cannot have out parameters. It can return a single value result or table, which is returned by the execute() call.
So, how would one go about calling a stored function using a CallableStatement?