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

Like parameter in DB2


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
MGayathri

New User


Joined: 19 May 2007
Posts: 25
Location: Chennai

PostPosted: Wed Nov 28, 2007 4:57 pm
Reply with quote

How to retrieve records having % in a field using DB2 Like parameter

Example:
PCT
10%
100%
20
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Nov 28, 2007 5:03 pm
Reply with quote

To search for a % or an _ as a literal part of your string, use the ESCAPE clause

Example-
Code:

   SELECT EMPNO, EMPNAME, WORKDEPT             FROM    EMP                                                            WHERE EMPNAME LIKE ‘ANURAG+_KAPOOR%'
                   ESCAPE ‘+’
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Nov 28, 2007 5:43 pm
Reply with quote

MGayathri,

I think your requirement is to retrieve the records that have character "%" in any position in the column data.

If yes, please check with the following code for your requirement as muthuvel suggested.

Code:
SELECT COLUMN_NAME FROM TABLE_NAME  WHERE COLUMN_NAME LIKE '%+%%' ESCAPE '+'
Back to top
View user's profile Send private message
MGayathri

New User


Joined: 19 May 2007
Posts: 25
Location: Chennai

PostPosted: Wed Nov 28, 2007 10:25 pm
Reply with quote

Muthuvel and Shanker.. Thanks a lot..
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Using the Jobname parameter in a Qual... ABENDS & Debugging 1
No new posts Demand with DEADLINE TIME parameter CA Products 4
No new posts Option DYNALLOC second parameter. DFSORT/ICETOOL 11
No new posts Writing the output file name from a p... JCL & VSAM 7
No new posts Reference for COND parameter. JCL & VSAM 1
Search our Forums:

Back to Top