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 -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm


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