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

Can 'Like' can have a VARIABLE value


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Mon Mar 16, 2009 8:10 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Mar 16, 2009 8:30 am
Reply with quote

Hello,

Not sure how this fits LIKE. . .

Probably i misunderstand, but why not use the values with OR's?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Mar 16, 2009 9:00 am
Reply with quote

or IN.
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Mon Mar 16, 2009 10:07 am
Reply with quote

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
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Mon Mar 16, 2009 1:35 pm
Reply with quote

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
View user's profile Send private message
tarun_bhardwaj

New User


Joined: 18 Jul 2003
Posts: 39
Location: delhi

PostPosted: Mon Mar 16, 2009 2:35 pm
Reply with quote

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
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Mon Mar 16, 2009 2:40 pm
Reply with quote

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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top