View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hi,
I have got a requirement where I need to use Like clause.
but this Like can have a VARIABLE value.
Example,
It can have value as 00349 or 00550 or any other value.
How do I retrieve this from database ?
Please advise. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Not sure how this fits LIKE. . .
Probably i misunderstand, but why not use the values with OR's? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
or IN. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi ap_mainframes,
If you are uncertain about what you are going to retrieve then it is better to fetch all the datas without any condition. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
ap_mainframes,
If this is a cobol DB2 program then you can make use of the host varibales without 'LIKE'.
If you are aware of only part of the varibale field then you may try using LIKE in the following manner:
Assuming the field length be Char(08)...then for 00349... you serach with
LIKE '00349%%%' ...for 00550 ..LIKE '00550%%%' ...and so on ,keep moving the part of the field in to the variable.
WTF |
|
Back to top |
|
|
tarun_bhardwaj
New User
Joined: 18 Jul 2003 Posts: 39 Location: delhi
|
|
|
|
You can use a host variable to achieve this. We have this running in our shop.
Code: |
AND ACC.ACCT_NUM LIKE :ACC-ACCT-NUM |
|
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
ap_mainframes wrote: |
Hi,
I have got a requirement where I need to use Like clause.
but this Like can have a VARIABLE value.
Example,
It can have value as 00349 or 00550 or any other value.
How do I retrieve this from database ?
Please advise. |
Hi ap_mainframes,
If your intension is only to use LIKE clause, then use pad '%' variable with the variable value.
Eg
Let say A1=00349, then A= 00%
Note: If you want to retrieve the data which starts with 00
Use this variable in the Like clause, hope this fulfil your requirement.
Please correct me if i misunderstood something else |
|
Back to top |
|
|
|