ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c.ze...@ads.it
Subject stored function: NUMBER result, NUMBER IN parameter
Date Mon, 20 Nov 2006 15:37:22 GMT


The TIPO_DATO_RIGA package declares the following overloaded versions of
the exists_id() method in its interface

   function exists_id
   ( p_tipo_riga_ID  in number(10)
   ) return number;
   pragma restrict_references( exists_id, WNDS );

   function exists_id
   ( p_tipo_dato_ID  in number(10)
   , p_nome          in varchar2(30)
   ) return number;
   pragma restrict_references( exists_id, WNDS );


Here is the SQL map

      <procedure id="esisteTipoRiga" parameterClass="java.util.Map">
        {#result,mode=OUT,javaType=java.lang.Integer,jdbcType=NUMBER# =
call tipo_dato_riga.exists_id( #pId
,javaType=java.lang.Integer,jdbcType=NUMBER,mode=IN# ) }
      </procedure>

and the Java code that calls it

      SqlMapClient lSqlMapClient = Configurazione.getSqlMapIstanza();

      Integer lInteger;
      HashMap< String, Integer > lHashMap = new HashMap< String, Integer
>();
      lHashMap.put( "pId", new Integer( 1234 ) );

        try
        {
            lSqlMapClient.update( "esisteTipoRiga", lHashMap );
        }
        catch (SQLException pException)
        {
            pException.printStackTrace();
            throw pException;
        }
      lInteger = lHashMap.get( "result" );
       boolean lResult = lInteger.intValue() == 1;

causes the following diagnostic

--- The error occurred in it/finmatica/gpj/aa/frontebd/TipoRiga.xml.
--- The error occurred while executing update procedure.
--- Check the {? = call tipo_dato_riga.exists_id( ? ) }.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: Invalid column type
Caused by: java.sql.SQLException: Invalid column type
      at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(
GeneralStatement.java:91)
      at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(
SqlMapExecutorDelegate.java:500)
      at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(
SqlMapSessionImpl.java:85)

Please note that the following PL/SQL

declare
  lId number;
  lResult number;
begin
  lId := 1234;
  lResult := tipo_dato_riga.exists_id( lId );
  dbms_output.put_line( 'here we are...' );
  dbms_output.put_line( 'lId = ' || lId || ', lResult = ' || lResult );
end;

works fine.
What's wrong in the SQL map / java code?
Any hint?
Is there any simpler approach on the Java side?

Thanks in advance
Mime
View raw message