ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Fagan <mfa...@tde.com>
Subject Re: fetch out of sequence
Date Fri, 02 Dec 2005 17:48:18 GMT
Juan,

I have seen this behavior once when the cursor did not return any rows. 
There must be a check I am missing, I will try to replicate the problem 
to get you a solution.

Regards,
Mike Fagan


Juan CaƱadas wrote:

> Hi
>
> I'm trying to get a list of values from an oracle stored procedure....
>
> I've been updated ibates to support oracle's cursor 
> (http://opensource2.atlassian.com/confluence/oss/display/IBATIS/Oracle+REF+CURSOR+Solutions)

>
> but when i run the program it raises the error:
> --------------------
> Caused by: java.sql.SQLException: ORA-01002: fetch out of sequence
>
>   at 
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)

>
> --------------------
>
> Oracle code:
>
> CREATE OR REPLACE Package TypesPackage AS
>     TYPE ref_cursor IS REF CURSOR;
>  END TypesPackage;
> /
>
> CREATE OR REPLACE PACKAGE BODY SYSPackage is
>   PROCEDURE getUsuariosCursor (usuariosCursor OUT 
> TypesPackage.ref_cursor) AS          BEGIN
>       OPEN usuariosCursor FOR
>           SELECT userid, login, tipousr, descr, email FROM usuario 
> ORDER BY login;
>   END getUsuariosCursor;
> END;
> /
>
> --------------------
> usuario.xml:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE sqlMap
> PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
> "http://www.ibatis.com/dtd/sql-map-2.dtd">
> <sqlMap namespace="Usuario">
> <typeAlias alias="usuario" 
> type="es.miEmpresa.miProyecto.modelo.Usuario" />
>
> <resultMap id="getUsuarioRef" class="usuario">
>   <result property="id" column="userid" />
>   <result property="login" column="login" />
>   <result property="tipo" column="tipousr" />
>   <result property="descripcion" column="descr" />
>   <result property="email" column="email" />
> </resultMap>
>
> <parameterMap id="getUsuariosRefPM" class="map">
>   <parameter property="usuariosCursor" jdbcType="ORACLECURSOR" 
> mode="OUT" resultMap="getUsuarioRef" />
> </parameterMap>
>
> <procedure id="getUsuariosRef" parameterMap="getUsuariosRefPM">
>   { call SYSPackage.getUsuariosCursor(?) }
> </procedure>
>
> </sqlMap>
> --------------------
> and the java source:
>
>       Map map = new HashMap();
>       //List list;
>       try {
>           Prueba.sqlMap.queryForObject("getUsuariosRef", map);
>           System.out.println(map.get("usuariosCursor"));
>       }catch(Exception e){
>           e.printStackTrace();
>       }
>
> Can anyone help me? what is wrong? how can i solve this problem? i'm 
> newbie in java and ibates...
>
> Thanks
>


Mime
View raw message