Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Like Clause Alternative

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jan 02, 2013 7:32 pm    Post subject: Like Clause Alternative
Reply with quote

Hi,

We are trying to run this query through Java Application (Hibernate Interface)

Code:
<query>
select col1,col2
        from AccountReference accountReference
        where lower(accountReference.accountReferenceIdExternal) like lower(?)||'%' escape '\'
</query>


Here "?" refers to Host variable value, we want to append "%" also in the like clause.

This is not working in java. But when I try to run the same query through DB2 client, (Data studio), Its working.

Can you please help on this?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8004
Location: Bellevue, IA

PostPosted: Wed Jan 02, 2013 8:09 pm    Post subject:
Reply with quote

Have you tried using %% instead of % since the % has a special meaning to Java?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1476
Location: Chennai

PostPosted: Wed Jan 02, 2013 11:21 pm    Post subject:
Reply with quote

Hello,
Could you try changing
Code:
like lower(?)||'%'

to
Code:
like (lower(?) + "%")
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Jan 03, 2013 3:42 pm    Post subject:
Reply with quote

Hi,

I tried all the above... only this works fine

Code:
<query>
select col1,col2
        from AccountReference accountReference
        where lower(accountReference.accountReferenceIdExternal) like lower(?)||'%' escape '\'
</query>


But I get the Sql code -132

Is there any way to append % clause to the host variable to make the query work?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts [SQL0029] INTO clause missing from em... HABBIE DB2 2 Fri Sep 04, 2015 3:54 pm
No new posts 3-D Table with nested DEPENDING ON Cl... VivekKhanna COBOL Programming 5 Sat Aug 08, 2015 11:18 pm
No new posts when=group clause: question about the... tuxama DFSORT/ICETOOL 2 Thu Mar 26, 2015 12:51 pm
No new posts Alternative to CALL tso command jerryte TSO/ISPF 6 Fri Aug 29, 2014 12:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us