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 "Deshpande, Bhushan M (IT)" <Bh...@morganstanley.com> on 2005/08/31 14:26:34 UTC

stored proc doesn't return output parameter

Hi All ,
   I am using Ibatis 2.1.5 to execute a stored proc on sybase databse
which retuns a string result .
----------------------
Entries in contiguration xml file is 
<parameterMap id="getContactParameters" class="map" >

<parameter property="contactId" jdbcType="INTEGER"
javaType="java.lang.Integer" mode="IN"/>

<parameter property="firstName" jdbcType="VARCHAR"
javaType="java.lang.String" mode="OUT"/>

</parameterMap>

<procedure id="spGetContacts" parameterMap="getContactParameters" >

{? sp_sample_get_contact (?)} 

</procedure>

 

also tried 

{? = call sp_sample_get_contact (?)}  but of no avail ;(

-----------------------------

Code in the servlet  for excution 

Reader configReader = Resources.getResourceAsReader("SqlMapConfig.xml");

SqlMapClient sqlMap =
SqlMapClientBuilder.buildSqlMapClient(configReader); 

sqlMap.startTransaction();

HashMap paramMap = new HashMap();

paramMap.put("firstName","");

paramMap.put("contactId", new Integer(1));

sqlMap.queryForObject("spGetContacts", paramMap);

String firstName = (String) paramMap.get("firstName");

sqlMap.commitTransaction();

-----------------------------------------------

Variable FirstName returns "0" instead of expected result .

However if the same operation is tried with simple query way it works
fine .

<select id="getContact" parameterClass="int"
resultClass="contact">select FIRSTNAME as firstName,LASTNAME as
lastName, CONTACTID as contactId from CONTACT where CONTACTID =
#contactId#</select>

Thanks for your all help in advance .
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited.

Re: stored proc doesn't return output parameter

Posted by Jeff Butler <je...@gmail.com>.
Try reordering the parameters in your parameter map. The first parameter 
should be the String OUT parameter, the second parameter should be the 
Integer IN parameter.
 Jeff Butler

 On 8/31/05, Deshpande, Bhushan M (IT) <Bh...@morganstanley.com> 
wrote: 
> 
>  Hi All ,
>  I am using Ibatis 2.1.5 to execute a stored proc on sybase databse which 
> retuns a string result .
> ----------------------
> Entries in contiguration xml file is 
>  
> <parameterMap id="getContactParameters" class="map" >
> 
> <parameter property="contactId" jdbcType="INTEGER" javaType="
> java.lang.Integer" mode="IN"/>
> 
> <parameter property="firstName" jdbcType="VARCHAR" javaType="
> java.lang.String" mode="OUT"/>
> 
> </parameterMap>
> 
> <procedure id="spGetContacts" parameterMap="getContactParameters" >
> 
> {? sp_sample_get_contact (?)} 
> 
> </procedure>
> 
>  also tried 
> 
> {? = call sp_sample_get_contact (?)} but of no avail ;(
> 
> -----------------------------
> 
> Code in the servlet for excution 
> 
> Reader configReader = Resources.getResourceAsReader("SqlMapConfig.xml");
> 
> SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(configReader); 
> 
> sqlMap.startTransaction();
> 
> HashMap paramMap = new HashMap();
> 
> paramMap.put("firstName","");
> 
> paramMap.put("contactId", new Integer(1));
> 
> sqlMap.queryForObject("spGetContacts", paramMap);
> 
> *String firstName = (String) paramMap.get("firstName");*
> 
> sqlMap.commitTransaction();
> 
> -----------------------------------------------
> 
> Variable FirstName *returns "0" instead of expected result .*
> 
> However if the same operation is tried with simple query way it works fine 
> .
> 
> <
> select id="getContact" parameterClass="int" resultClass="contact">select 
> FIRSTNAME as firstName,LASTNAME as lastName, CONTACTID as contactId from 
> CONTACT where CONTACTID = #contactId#</select> 
> 
> Thanks for your all help in advance .
>  ------------------------------
>  
> NOTICE: If received in error, please destroy and notify sender. Sender 
> does not waive confidentiality or privilege, and use is prohibited.
>