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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm


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