Spring Mybatis Oracle函数调用

时间:2016-07-14 18:52:34

标签: mybatis ibatis spring-mybatis

我在调用oracle函数时遇到以下错误...

    org.springframework.jdbc.UncategorizedSQLException: 
### Error querying database.  Cause: java.sql.SQLException: Non supported SQL92 token at position: 1: 
### The error may exist in file [C:\Users\pkr\rpt\bin\dbmappers\MyMapper.xml]
### The error may involve com.pkr.tpy.rpt.dao.MyDao.resetRecs-Inline
### The error occurred while setting parameters
### SQL: {    ? = call actions.reset_recs(?,                  ?,                  ?,                  ?)    }
### Cause: java.sql.SQLException: Non supported SQL92 token at position: 1: 
; uncategorized SQLException for SQL []; SQL state [99999]; error code [17034]; Non supported SQL92 token at position: 1: ; nested exception is java.sql.SQLException: Non supported SQL92 token at position: 1: 
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
    at com.sun.proxy.$Proxy37.selectOne(Unknown Source)

这是我的mapper.xml

<select id="resetRecs" resultType="String"   statementType="CALLABLE">  
    {
    #{retVal,mode=OUT,jdbcType=VARCHAR} = call actions.reset_recs(#{xCode, jdbcType=DECIMAL,mode=IN},
                                 #{yCode,jdbcType=DECIMAL,mode=IN},
                                 #{xyzNum,jdbcType=DECIMAL,mode=IN},
                                 #{src,jdbcType=VARCHAR,mode=IN}) 
    }       
</select>

DAO Interface:

String resetRecs(@Param("xCode") int xCode,
            @Param("yCode") int yCode,
            @Param("xyzNum") int xyzNum, @Param("xyzSrc") String xyzSource,
            @Param("retVal") String retVal);

我使用Mybatis 3.4.0,非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

当我在一行中更新我的mapper调用语句时,我能够解决这个问题。

<select id="resetRecs" resultType="String"   statementType="CALLABLE">  
{#{retVal,mode=OUT,jdbcType=VARCHAR} = call actions.reset_recs(#{xCode, jdbcType=DECIMAL,mode=IN},#yCode,jdbcType=DECIMAL,mode=IN},#xyzNum,jdbcType=DECIMAL,mode=IN},#{src,jdbcType=VARCHAR,mode=IN})}