I'm trying to execute an Oracle stored procedure, and map the results to a POJO, with mybatis/spring using annotations (i.e. not XML). The inputs/outputs for the stored procedure are:
P_INPUT VARCHAR2 IN
P_OUTPUT VARCHAR2 OUT
P_COUNT BINARY_INTEGER OUT
And the POJO looks like this:
public class MyRecord {
private String output;
private Integer count;
// getters and setters...
}
The snippet in this example, which says it's for Oracle, worked perfectly for me against a MySQL stored procedure. However, when I tried to execute the following against an Oracle stored procedure:
@Select(value= "{ CALL my_user.some_package.my_proc('${input}') }")
@Options(statementType = StatementType.CALLABLE)
@ResultType(MyRecord.class)
@Results({
@Result(property="output", column="P_OUTPUT"),
@Result(property="count", column="P_COUNT"),
})
MyRecord parseMyInput(@Param("input") String input);
... it threw the following error:
bad SQL grammar []; nested exception is java.sql.SQLException: ORA-06550
PLS-00306: wrong number or types of arguments in call to 'my_proc'
PL/SQL: Statement ignored
From the error message, it sounds like the string being passed to the function may be incompatible with Oracle's VARCHAR2
, or I'm somehow sending more than one argument. The string that I'm passing to the function, incidentally, is (12345)
.
Can you see what I'm doing wrong?