You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Miquel Angel Bada Zuazo <ma...@gmail.com> on 2006/04/05 09:59:59 UTC

problem executing an Stored Procedure with SQL Server and IBatis

 Hi,

I'm developing a call to an Stored Procedure with SQL SERVER, and when I try
to map, it throws an SQL Exception


com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in
com/hermes/persistence/sqlmapdao/sql/Accounts.xml.
--- The error occurred while applying a parameter map.
--- Check the Accounts.paramSearchAccountList.
--- Check the statement (update procedure failed).
--- Cause: java.sql.SQLException: Formal parameter '@Deleted' was defined as
OUTPUT but the actual parameter not declared OUTPUT.
Caused by: java.sql.SQLException: Formal parameter '@Deleted' was defined as
OUTPUT but the actual parameter not declared OUTPUT.

(also I got a SQLStatment 37000 :( )

the code is the following:

--------XML-------

<parameterMap id="paramSearchAccountList" class="java.util.HashMap" >
        <parameter property="clientName" jdbcType="VARCHAR" javaType="
java.lang.String" mode="IN"/>
        <parameter property="role" jdbcType="VARCHAR" javaType="
java.lang.String" mode="IN"/>
        <parameter property="VATNumber" jdbcType="VARCHAR" javaType="
java.lang.String" mode="IN"/>
        <parameter property="currency" jdbcType="VARCHAR" javaType="
java.lang.String" mode="IN"/>
        <parameter property="deleted" jdbcType="BIT" javaType="
java.lang.Integer" mode="INOUT"/>
        <parameter property="NumRecordsRetrieved" jdbcType="INTEGER"
javaType="java.lang.Integer" mode="INOUT"/>
        <parameter property="list" jdbcType=" java.util.list" mode="OUT"
resultMap="usu"/>
      <!--    <parameter property="list" jdbcType="INTEGER" mode="OUT" />
-->
   </parameterMap>

   <procedure  id="getAllAccounts" resultMap="accountsList"
parameterMap="paramSearchAccountList">
      {
        call CPGHermesAccountsSearch (?, ?, ?, ?, ?, ?)
      }
   </procedure>
--------JAVA-------------

public PaginatedList getListAccounts(HashMap map) throws SQLException {
      PaginatedList list = null;
      try{
      //  list = sqlMap.queryForPaginatedList("Accounts." + GET_ALL +
"Accounts", map, 1);
        list = (PaginatedList) sqlMap.queryForObject("Accounts." + GET_ALL +
"Accounts", map);

      }
       catch (SQLException e) {
           throw (e);
         //   logger.error("Error getting departments", e);
       }
      return list;
  }
-----------------------
If I execute the SP in SQL Analyzer, it works fine, but with ibatis, there
may be some missconfiguration with the parameters, does anybody knows what
do I'm doing wrong?

Sincerely yours,

Miquel Angel

Re: problem executing an Stored Procedure with SQL Server and IBatis

Posted by Larry Meadors <lm...@apache.org>.
The number of parameters looks wrong - i see 6 "?" chars, and 7 parameter tags.

The "deleted" parameter seems to think it is OUT only, but it INOUT in
the parameter map.

Larry


On 4/5/06, Miquel Angel Bada Zuazo <ma...@gmail.com> wrote:
>
>
> Hi,
>
> I'm developing a call to an Stored Procedure with SQL SERVER, and when I try
> to map, it throws an SQL Exception
>
>
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in
> com/hermes/persistence/sqlmapdao/sql/Accounts.xml.
> --- The error occurred while applying a parameter map.
> --- Check the Accounts.paramSearchAccountList.
> --- Check the statement (update procedure failed).
> --- Cause: java.sql.SQLException: Formal parameter '@Deleted' was defined as
> OUTPUT but the actual parameter not declared OUTPUT.
> Caused by: java.sql.SQLException: Formal parameter '@Deleted' was defined as
> OUTPUT but the actual parameter not declared OUTPUT.
>
> (also I got a SQLStatment 37000 :( )
>
> the code is the following:
>
> --------XML-------
>
> <parameterMap id="paramSearchAccountList" class="java.util.HashMap" >
>         <parameter property="clientName" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN"/>
>         <parameter property="role" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN"/>
>         <parameter property="VATNumber" jdbcType="VARCHAR" javaType="
> java.lang.String" mode="IN"/>
>         <parameter property="currency" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN"/>
>         <parameter property="deleted" jdbcType="BIT" javaType="
> java.lang.Integer" mode="INOUT"/>
>         <parameter property="NumRecordsRetrieved" jdbcType="INTEGER"
> javaType="java.lang.Integer" mode="INOUT"/>
>         <parameter property="list" jdbcType=" java.util.list" mode="OUT"
> resultMap="usu"/>
>       <!--    <parameter property="list" jdbcType="INTEGER" mode="OUT" />
> -->
>    </parameterMap>
>
>    <procedure  id="getAllAccounts" resultMap="accountsList"
> parameterMap="paramSearchAccountList">
>       {
>         call CPGHermesAccountsSearch (?, ?, ?, ?, ?, ?)
>       }
>     </procedure>
> --------JAVA-------------
>
> public PaginatedList getListAccounts(HashMap map) throws SQLException {
>       PaginatedList list = null;
>       try{
>       //  list = sqlMap.queryForPaginatedList("Accounts." + GET_ALL +
> "Accounts", map, 1);
>         list = (PaginatedList) sqlMap.queryForObject("Accounts." + GET_ALL +
> "Accounts", map);
>
>       }
>        catch (SQLException e) {
>            throw (e);
>          //   logger.error("Error getting departments", e);
>        }
>       return list;
>   }
> -----------------------
> If I execute the SP in SQL Analyzer, it works fine, but with ibatis, there
> may be some missconfiguration with the parameters, does anybody knows what
> do I'm doing wrong?
>
> Sincerely yours,
>
>
>
> Miquel Angel