ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: SQLMaps - Sybase and stored procedures
Date Tue, 09 Aug 2005 11:01:54 GMT
It's true: Without a resultMap or resultClass, your results will be
silently discarded.

Larry


On 8/9/05, Priyesh Mashelkar <priyeshm@mastek.com> wrote:
> Use a resultMap or resultClass as you would do for a normal query.
> They have missed mention of procedures returning values in their documentation.
> 
> Your mapping would look like:
> 
> <parameterMap id="languageLookupMap" class="java.util.HashMap">
>       <parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
> property="from_text"/>
>       <parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
> property="language"/>
> </parameterMap>
> 
> <procedure id="languageLookup"  parameterMap="languageLookupMap" resultClass="java.lang.String">
>       {call language_lookup @from_text = ?, @language = ?}
> </procedure>
> 
> The call remains the same. i.e.,       {call language_lookup @from_text = ?, @language
= ?}.
> 
> 
> -----Original Message-----
> From: andrew.scott@jpmchase.com [mailto:andrew.scott@jpmchase.com]
> Sent: Tuesday, August 09, 2005 4:21 PM
> To: user-java@ibatis.apache.org
> Subject: SQLMaps - Sybase and stored procedures
> 
> 
> Hi,
> 
> I have a question regarding the use of stored procedures (in particular
> Sybase) with SQLMaps.
> Having looked at the documentation I am still unsure as the documentation,
> unless I have missed it, doesnt deal with getting results back from
> the proc.
> 
> I wish to call a Sybase stored procedure, passing into two parameters and
> retrieving a String value in a resultset.
> The proc, which provides a language translation, takes two String
> parameters (the text you wish translated, and the language
> you wish translated to) and then returns a String value of the translated
> text.
> 
> 
> 
> My sqlmap is as follows:
> 
> <parameterMap id="languageLookupMap" class="java.util.HashMap">
>       <parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
> property="from_text"/>
>       <parameter javaType="java.lang.String" mode="IN" jdbcType="VARCHAR"
> property="language"/>
> </parameterMap>
> 
> <procedure id="languageLookup"  parameterMap="languageLookupMap">
>       {call language_lookup @from_text = ?, @language = ?}
> </procedure>
> 
> 
> 
> My code is as follows:
> 
> HashMap map = new HashMap();
> map.put("from_text", "Computers");
> map.put("language", "FRE");
> 
> ArrayList results = (ArrayList) sqlMap.queryForList("testLanguageLookup",
> map);
> iter = results.iterator();
> System.out.println("results = " + results.toString());
> 
> 
> When I run the code, the output is always "result = []".
> 
> 
> 
> 
> 
> However, if I run the following regular jdbc code, I get a valid result:
> 
> CallableStatement cstmt = conn.prepareCall("{call language_lookup
> @from_text = 'Computers', @language = 'FRE'}");
> ResultSet rs = cstmt.executeQuery();
> 
> System.out.println("Resultset = " + rs.toString());
> rs.next();
> String output = (String) rs.getString(1);
> System.out.println("Output = " + output);
> 
> 
> 
> The output is ----->
> 
> Resultset = com.sybase.jdbc2.jdbc.SybResultSet@5fc75b3
> Output = Ordinateurs
> 
> 
> 
> 
> Can anyone give me some tips to get the same eresults with SQLMaps as I get
> with regular jdbc code?
> 
> Thanks in advance,
> andy
> 
> 
> 
> 
> MASTEK
> "Making a valuable difference"
> Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
> In the US, we're called MAJESCO
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Opinions expressed in this e-mail are those of the individual and not that of Mastek
Limited, unless specifically indicated to that effect. Mastek Limited does not accept any
responsibility or liability for it. This e-mail and attachments (if any) transmitted with
it are confidential and/or privileged and solely for the use of the intended person or entity
to which it is addressed. Any review, re-transmission, dissemination or other use of or taking
of any action in reliance upon this information by persons or entities other than the intended
recipient is prohibited. This e-mail and its attachments have been scanned for the presence
of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails
and attachments before opening them. If you have received this e-mail in error, kindly delete
this e-mail from all computers.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>

Mime
View raw message