[英]Calling stored procedure with @Query results in Exception: wrong number or types of arguments in call to ProcedureName
I have an issue with calling a stored procedure我在调用存储过程时遇到问题
create or replace PROCEDURE TProc1
(i_cob_date IN DATE,
i_location IN VARCHAR2,
o_ret OUT VARCHAR2
)
AS
BEGIN
--logic to update a table based on i_cob_date
o_ret := '0';
commit;
END TProc1;
public interface MyRepository extends CrudRepository<MyEntity, Long> {
@Query(value = "call TProc1(:i_cob_date, :i_location)", nativeQuery = true)
String markStatus(@Param("i_cob_date")Date cobDate, @Param("i_location")String location);
}
I am using SpringBoot with Spring Data JPA, when i tried to invoke the method I got below error.我将 SpringBoot 与 Spring Data JPA 一起使用,当我尝试调用出现以下错误的方法时。
Could not extract the ResultSet
Caused by: java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to 'TProc1'
You have declared your stored procedure with three parameters, but you are calling it only with two in the SQL script in the @Query
annotation.您已经使用三个参数声明了您的存储过程,但在@Query
注释的 SQL 脚本中仅使用两个参数来调用它。
Once that is fixed you will run in the next problem, because your script doesn't return a value.一旦修复,您将在下一个问题中运行,因为您的脚本不返回值。 JPA wouldn't know what to return from that and therefore the same is true for Spring Data JPA. JPA 不知道从中返回什么,因此 Spring Data JPA 也是如此。 I'm not at all sure if that can be fixed with the approach you choose.我完全不确定您选择的方法是否可以解决这个问题。
For calling stored procedures with JPA I highly recommend declaring them using @NamedStoredProcedureQuery
.对于使用 JPA 调用存储过程,我强烈建议使用@NamedStoredProcedureQuery
声明它们。 You can then access that stored procedure using Spring Data JPA .然后,您可以使用 Spring Data JPA 访问该存储过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.