ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balaji" <bal...@objectec.com>
Subject Sybase proc with return value, results, IN & OUT params
Date Wed, 11 Jan 2006 18:50:35 GMT
I am trying to call a sybase stored proc which returns results set and a return value, has
input paramters & output parameters. 

I need to know how to to get the 
1. return value ( 0 on success, -1 on failure)
2. out parms values - as_error, as_error_msg
3. Result set list ( if success)

Thanks,
Balaji


/******************************************************/
ERROR 
/******************************************************/

com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in unitTest/domain/f3721.xml.  
--- The error occurred while applying a parameter map.  
--- Check the F3721.GetAppsParam.  
--- Check the results (failed to retrieve results).  
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
at unitTest.domain.DomainTest.main(DomainTest.java:41)

/*****************************************************************/
JAVA CODE:
/*****************************************************************/

public static Integer callProc() {
 Map param = new HashMap();
 param.put("value", new Integer(-1));
 param.put("userid", "testuser");
 //param.put("userid", "");  //for this too

 try {
     List list = sqlMap.queryForList("getApps", param);
 } catch (SQLException sqe) {
    sqe.printStackTrace(); 
 }

   System.out.println("as_error=" + param.get("as_error"));
   System.out.println("as_error_msg=" + param.get("as_error_msg"));
   return (Integer)param .get("value");
}

/*****************************************************************/
STORED PROCEDURE:
/*****************************************************************/

CREATE  PROCEDURE proc_get_applist

(
      @as_userid         typ_ch_userid,
     @as_error            char(5) OUTPUT,
     @as_error_msg       varchar(255) OUTPUT
)

AS

--Check key values
IF @as_userid IS NULL OR @as_userid = ""
   BEGIN
  SELECT  @as_error = '-1'
  SELECT  @as_error_msg = "Key values cannot be null."
      RETURN 1
   END


SELECT   t1.id_app, t1.cd_edit_status,    
FROM     application t1

RETURN 0

/*********************************************************************************/
SQL MAP
/*****************************************************************************
<parameterMap id="GetAppsParam" class="java.util.HashMap">
     <parameter property="value" jdbcType="INTEGER" javaType="java.lang.Integer" mode="OUT"/>
     <parameter property ="userid" jdbcType="VARCHAR" javaType="string" mode="IN"/>
     <parameter property ="as_error" jdbcType="VARCHAR" javaType="string" mode="INOUT"/>
     <parameter property ="as_error_msg" jdbcType="VARCHAR" javaType="string" mode="INOUT"/>

</parameterMap>


<resultMap id="getAppsResult" class="java.util.HashMap">
     <result property="id_app" column="ID_APP"/>
     <result property="dt_create" column="DT_CREATE"/> 
     <result property="cd_edit_status" column="CD_EDIT_STATUS" nullValue=""/> 
</resultMap>


<procedure id="getApps" parameterMap="GetAppsParam"    resultClass="getAppsResult" >
     { ? = call proc_get_applist(?,?,?)}
</procedure>



Mime
View raw message