Search code examples
ibatis

How to call function over data being passed in ibatis


I need to call a internal function say 'calculateValue(value)' which returns some string based on the value passed.

<select id="calculateValue" resultClass="java.lang.String" parameterClass="java.lang.String">
  SELECT calculateValue(#value#) FROM SYSIBM.SYSDUMMY1
</select>

the above query returns the below error.

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in mymapsql.xml.
--- The error occurred while executing query.
--- Check the SELECT calculateValue(?) FROM SYSIBM.SYSDUMMY1 .
--- Check the SQL Statement (preparation failed).
--- Cause: java.sql.SQLException: [SQL0418] Use of parameter marker not valid.

how to call the function calculateValue() on the value being passed as parameter?


Solution

  • use procedure tag <procedure> for calling stored procedure.

    <procedure id="procId" resultClass="ResultClass"
              parameterMap="getMap">
    { call getResult( #param# ) } 
    </procedure>