ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfs <farhan.sar...@gmail.com>
Subject Re: Calling a function with Integer param and return type an inline params
Date Sun, 25 May 2008 07:29:52 GMT

Is there a jdbctype 'integer' there ? I thought numeric is what u use instead
to represent the same...but anyways I will check ? 

Secondly its just seems an unnecessory overhead to me to create another
class of my own..just for the sake of holding/fetching an integer output
value..don't u think... 

Jeff Butler-2 wrote:
> 
> You might try setting the jdbcType of the OUT parameter to INTEGER.  If
> that
> doesn't work, then you'll need to define an actual class to hold your
> results (not just a Map).
> 
> Jeff Butler
> 
> On Sat, May 24, 2008 at 3:35 PM, mfs <farhan.sarwar@gmail.com> wrote:
> 
>>
>> Jeff
>>
>> with ur input i did get this to work, as below but please suggest if
>> there
>> is to be a better way to do this, also i am not getting the result of the
>> type i am expecting (i.e. it should be Integer instead of BigDecimal
>> which
>> i
>> believe the JDBC api is returning and certainly something i would want
>> avoid
>> typecasting after conversion)...so i want suggestion as whats the better
>> way
>> of doing this, now let me add that since my requirement is so minimal
>> (function call with integer param and integer  return type) i didnt knew
>> what better way to achieve it..like defining my own resultMap of class
>> "map" with one property i.e. stateId of type Integer? or ?? please
>> suggest...preferably with an example
>>
>>
>> Mapping File
>> ==========
>>  <procedure id="getState" >
>>         { #result,mode=OUT,javaType=java.lang.Integer,jdbcType=NUMERIC# =
>> call
>>
>> location.get_state(#stateId,javaType=java.lang.Integer,jdbcType=NUMERIC,mode=IN#)
>> }
>>  </procedure>
>>
>> DAO code - uses SqlMapDaoTemplate
>> ========
>>        Map parms = new HashMap();
>>        parms.put("p_location_id", new Integer(1));
>>        queryForObject("getStateIdByLocation", parms);
>>        BigDecimal stateId = (BigDecimal) parms.get("result"); <--
>> Expecting
>> Integer here
>>
>>
>> Thanks in advance..
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> mfs wrote:
>> >
>> > still doesnt work.. and as per the javadoc the
>> SqlMapDaoTemplate.update()
>> > javadoc "Executes a mapped SQL UPDATE statement", i dont think it will
>> > work here, just guessing..
>> >
>> >
>> > Jeff Butler-2 wrote:
>> >>
>> >> There's no result set here, so queryForObject won't work.  Try this in
>> >> your
>> >> DAO:
>> >>
>> >> Map parms = new HashMap();
>> >> parms.put("stateId", new Integer(1));
>> >> update("getState", parms);
>> >> Integer stateId = (Integer) parms.get("result");
>> >>
>> >> Jeff Butler
>> >>
>> >>
>> >>
>> >> On Sat, May 24, 2008 at 4:01 AM, mfs <farhan.sarwar@gmail.com> wrote:
>> >>
>> >>>
>> >>> Guys,
>> >>>
>> >>> I am trying to call an oracle function (using inline parameters) and
>> it
>> >>> just
>> >>> doesnt seem to work and returns null (though the same has been tested
>> >>> from
>> >>> a
>> >>> standalone plsql client returns the result as expected)..
>> >>>
>> >>> Can anyone suggest as to what the problem is in the code below, the
>> >>> oracle
>> >>> function takes a number argument and returns a number,
>> >>>
>> >>> DAO class
>> >>> -----
>> >>> Integer stateId = (Integer)queryForObject("getState", new
>> Integer(1));
>> >>> System.out.println(stateId);
>> >>>
>> >>> mapping.xml
>> >>> ------
>> >>>  <procedure id="getState" >
>> >>>         { #result,javaType=java.lang.Integer,jdbcType=NUMERIC# = call
>> >>>
>> >>>
>> location.get_state(#stateId,javaType=java.lang.Integer,jdbcType=NUMERIC,mode=IN#)
>> >>> }
>> >>>  </procedure>
>> >>>
>> >>> Thanks in advance
>> >>>
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/Calling-a-function-with-Integer-param-and-return-type-an-inline-params-tp17445906p17445906.html
>> >>> Sent from the iBATIS - User - Java mailing list archive at
>> Nabble.com.
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Calling-a-function-with-Integer-param-and-return-type-an-inline-params-tp17445906p17451630.html
>>  Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Calling-a-function-with-Integer-param-and-return-type-an-inline-params-tp17445906p17455235.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message