简体   繁体   English

如何使用实体管理器在 spring 中调用 oracle 存储过程?

[英]How to call oracle stored procedure in spring using entity manager?

create or replace PROCEDURE TEST  
(
Role IN VARCHAR2, 
     OUTPUT 
 OUT SYS_REFCURSOR
)
AS
BEGIN
 OPEN OUTPUT FOR   
Select PC.PRODUCT_NAME,P.PARTNER_NAME
............
.............
  WHERE PC.ROLE_NAME='POS_LEAD';
END TEST;

Calling above procedure In Spring using below code使用以下代码在 Spring 中调用上述程序

StoredProcedureQuery findByYearProcedure = entityManager.createStoredProcedureQuery("TEST");

StoredProcedureQuery storedProcedure = findByYearProcedure
            .registerStoredProcedureParameter("Role", String.class, ParameterMode.IN)
            .registerStoredProcedureParameter("SYS_REFCURSOR", Object.class,ParameterMode.REF_CURSOR);
            .setParameter("Role", "admin");

System.out.println(storedProcedure.getResultList());

But I am getting an error.但我收到一个错误。

 ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TEST' ORA-06550: line 1, column 7: PL/SQL: Statement ignored

can any one help?有人可以帮忙吗?

I tried to duplicate your issue but I cannot, though I'm using Postgres instead of Oracle.我试图复制您的问题,但我不能,尽管我使用的是 Postgres 而不是 Oracle。 Just to be sure, can you do this instead:可以肯定的是,您可以这样做吗:

StoredProcedureQuery storedProcedure = findByYearProcedure
            .registerStoredProcedureParameter(1, String.class, ParameterMode.IN)
            .registerStoredProcedureParameter(2, Object.class,ParameterMode.REF_CURSOR);
            .setParameter("Role", "admin");

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用实体管理器调用具有多个输入和输出参数的存储过程 - how to call stored procedure with multiple in and out parameters using entity manager 如何使用在Oracle数据库中调用存储过程所需的实体管理器创建Clob? - How to create a Clob with Entity Manager needed to call a stored procedure in an Oracle database? 如何使用 Hibernate 调用 Oracle 存储过程? - How to Call Oracle Stored Procedure using Hibernate? 如何使用spring和hibernate调用存储过程 - how to call stored procedure using spring and hibernate 如何使用mybatis调用oracle存储过程(基于注释)。 - How to call oracle stored procedure using mybatis (annotation based.) 使用spring存储过程调用oracle存储过程 - Calling oracle stored procedure using spring stored procedure 使用createNativeQuery调用Oracle存储过程 - Call Oracle Stored Procedure Using createNativeQuery 如何在spring框架中使用HibernateTemplate调用存储过程? - How to call a stored procedure using HibernateTemplate in spring framework? 如何使用hibernate在spring boot中调用MySQL存储过程? - how to call MySQL stored procedure in spring boot using hibernate? 如何使用Spring调用带有ref游标作为输出参数的存储过程? - How to call a stored procedure with ref cursor as an output parameter using Spring?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM