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
 

 

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 Select numeric portion from CHAR data... balaji81_k DB2 1 Sat Aug 19, 2017 1:51 am
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am


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