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
 

 

Can 'Like' can have a VARIABLE value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Can 'Like' can have a VARIABLE value
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

Site Director


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

PostPosted: Mon Mar 16, 2009 8:30 am    Post subject:
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    Post subject:
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    Post subject: Reply to: Like
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    Post subject: Reply to: Do 'Like' can have a VARIABLE value
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    Post subject:
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: 95
Location: India

PostPosted: Mon Mar 16, 2009 2:40 pm    Post subject: Re: Do 'Like' can have a VARIABLE value
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    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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


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