Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Select statement with like using host variable

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

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Tue Sep 25, 2007 12:05 pm    Post subject: Select statement with like using host variable
Reply with quote

I am trying to select multiple rows from my table.
by using the cursor option in my cobol program.(embedded sql)
in my select statement i am trying to use like.
Select Custid,custname from table where custid like :id.
the id gets the value from the screen.
it is a varchar field.
on the screen if type "S" i should be able to retrieve all the rows that has S.
if hard code it in my select statement 's%' it is working.
but if i pass the value to id s% it is not retrieving.
need to understand how like will work with the host variable.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Sep 25, 2007 5:18 pm    Post subject: Re: Select statement with like using host variable
Reply with quote

ramco_sita wrote:
I am trying to select multiple rows from my table.
by using the cursor option in my cobol program.(embedded sql)
in my select statement i am trying to use like.
Select Custid,custname from table where custid like :id.
the id gets the value from the screen.
it is a varchar field.
on the screen if type "S" i should be able to retrieve all the rows that has S.
if hard code it in my select statement 's%' it is working.
but if i pass the value to id s% it is not retrieving.
need to understand how like will work with the host variable.

Put the 's' in the first position of the host variable ID and fill the remainder with '_'.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Sep 25, 2007 11:08 pm    Post subject:
Reply with quote

Really? underscores, never would have even thought of that. Is it documented in the manual?
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Wed Sep 26, 2007 9:32 am    Post subject:
Reply with quote

we did try putting % using inspect statement in cobol , but the DCLGEN variable gets some junk values and so it is not able to find the selected row.
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 Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us