简体   繁体   English

使用 Mybatis 将 boolean 参数传递给存储过程

[英]Passing boolean parameter to stored procedure with Mybatis

I am trying to call Oracle PL/SQL procedure with Mybatis in Spring project.我试图在 Spring 项目中使用 Mybatis 调用 Oracle PL/SQL 过程。 However I am getting below error: Caused by: java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to但是我遇到以下错误:引起:java.sql.SQLException: ORA-06553: PLS-306: arguments 的数量或类型错误

Problem is with boolean parameter because when I remove it it works well.问题在于 boolean 参数,因为当我删除它时它运行良好。 (process_now parameter is optional in procedure) The stored procedure works well when I am calling it with SQL Developer. (process_now 参数在过程中是可选的)当我使用 SQL Developer 调用存储过程时,它运行良好。

 <select id="processUser" statementType="CALLABLE" parameterType="UserResult">
 CALL myprocedure(
            user_id => #{userId, jdbcType=NUMERIC, mode=IN},
            description => #{description, jdbcType=VARCHAR, mode=IN},
            process_now => #{processNow, jdbcType=BOOLEAN, mode=IN},
            response => #{response, jdbcType=NUMERIC, mode=OUT}
        )

What could be the problem?可能是什么问题呢?

I solved the issue by creating new custom wrapper procedure and declaring boolean variables within it.我通过创建新的自定义包装程序并在其中声明 boolean 变量解决了这个问题。 Then I passed those declared variables to my original procedure.然后我将这些声明的变量传递给我的原始程序。 That solved my problem.这解决了我的问题。

Here is the link to page: (Read 'Wrapping PL/SQL BOOLEAN, RECORD, and TABLE Types' part) https://docs.oracle.com/cd/F49540_01/DOC/java.815/a64684/typesup1.htm Here is the link to page: (Read 'Wrapping PL/SQL BOOLEAN, RECORD, and TABLE Types' part) https://docs.oracle.com/cd/F49540_01/DOC/java.815/a64684/typesup1.htm

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM