IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Like Clause Alternative


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jan 02, 2013 8:09 pm
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: 1742
Location: Tirupur, India

PostPosted: Wed Jan 02, 2013 11:21 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
No new posts usage of CASE in WHERE clause DB2 10
No new posts Cobol redefines for Signed pictured c... COBOL Programming 4
Search our Forums:

Back to Top