2

我试图调用一个只有一个输出参数而没有输入参数的存储过程。当我如下所示调用存储过程时,出现“调用中的参数数量或类型错误”错误

SimpleJdbcCall jdbcCall = new SimpleJdbcCall(springTemplate) 
.withCatalogName("my_package").withProcedureName("my_procedure")
.withReturnValue().withoutProcedureColumnMetaDataAccess()
.declareParameters(new SqlOutParameter("return", Types.VARCHAR));
 Map out = jdbcCall.execute();
 System.out.println((String)out.get("return"));

我不确定这里出了什么问题。我得到了错误

org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; 
bad SQL   grammar [{? = call my_package.my_procedure()}]; nested exception is 
java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'my_procedure'
ORA-06550: line 1, column 7:

任何帮助将不胜感激 PL/SQL: Statement被忽略

4

1 回答 1

4

我完全尝试了您所做的并且对我有用,请发布以下语句的结果:

select PACKAGE_NAME, OBJECT_NAME, POSITION, ARGUMENT_NAME, DATA_TYPE, IN_OUT
from USER_ARGUMENTS
where PACKAGE_NAME ='my_package' and OBJECT_NAME = 'my_procedure'
order by PACKAGE_NAME, OBJECT_NAME, POSITION

更新:
我想我发现了你的错误,引用'a stored procedure which only has one out parameter and no input parameter'。你有一个过程,而不是一个函数。在这种情况下,您必须编写:

SimpleJdbcCall jdbcCall = new SimpleJdbcCall(springTemplate) 
    .withCatalogName("my_package")
    .withProcedureName("my_procedure")
    .withoutProcedureColumnMetaDataAccess()
    .declareParameters(new SqlOutParameter("YOUR_OUTPARAMETER_NAME", Types.VARCHAR));
于 2013-01-31T13:41:21.883 回答