mybatis调用Oracle存储程序报SQL命令未正确结束

存储程序在navicat里测试过了 没有问题

XML代码

<select id="YD_ML"  parameterType="java.util.Map" statementType="CALLABLE">
        {call YD_ML(
            #{FBEGDATE,mode=IN,jdbcType=VARCHAR},
            #{FENDDATE,mode=IN,jdbcType=VARCHAR},
            #{PK_ORG,mode=IN,jdbcType=VARCHAR}
            )}
    </select>

报错代码

2019-04-20 21:05:41,745 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==>  Preparing: {call YD_ML( ?, ?, ? )} 
2019-04-20 21:05:41,756 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==> Parameters: '2019-01-01 00:00:00'(String), '2019-01-31 00:00:00'(String), '"01","0101"'(String)
org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLException: ORA-00933: SQL 命令未正确结束
ORA-06512: 在 "NC65.YD_ML", line 11
ORA-06512: 在 line 1

存储过程第11行是一行注释 有大佬知道是为什么吗


好像是单引号的问题 改了之后不报错 但是查不到数据
修改后的代码

            map.put("FBEGDATE","2019-01-01 00:00:00");
            map.put("FENDDATE","2019-01-31 00:00:00");
            map.put("PK_ORG","'''01''',''0101'''");

控制台

2019-04-20 23:22:25,250 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==>  Preparing: {call YD_ML( ?, ?, ? )} 
2019-04-20 23:22:25,270 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==> Parameters: 2019-01-01 00:00:00(String), 2019-01-31 00:00:00(String), '''01'',''0101'''(String)

1个回答

删掉引号就正常了... 但是需求是要引号的 服务器上面不加引号就会报错
我现在是这么添加的

map.put("PK_ORG","''"+pk_org+"''");

mapper文件

    <select id="YD_ML"  parameterType="java.util.Map" statementType="CALLABLE">
        {call YD_ML(
            #{FBEGDATE,mode=IN,jdbcType=VARCHAR},
            #{FENDDATE,mode=IN,jdbcType=VARCHAR},
            #{PK_ORG,jdbcType=VARCHAR,mode=IN}
            )}
    </select>

报错信息

2019-04-24 10:33:56,091 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==>  Preparing: {call YD_ML( ?, ?, ? )} 
2019-04-24 10:33:56,092 DEBUG [modules.demo.dao.ImUserDao.YD_ML] - ==> Parameters: 2019-01-01(String), 2019-04-24(String), ''01''(String)
org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: java.sql.SQLException: ORA-00907: 缺失右括号
ORA-06512: 在 "NC65.YD_ML", line 11
ORA-06512: 在 line 1

### The error may exist in file [E:\jeesite-master\src\main\webapp\WEB-INF\classes\mappings\modules\demo\ImUserDao.xml]
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!