IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Select statement with like using host variable


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
Search our Forums:

Back to Top