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
 

 

Like parameter in DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: Like parameter in DB2
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: Chennai

PostPosted: Wed Nov 28, 2007 5:03 pm    Post subject: Reply to: Like parameter in DB2
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can DFSPARM override SORTKEYS paramet... ashek15 DB2 2 Tue Jan 31, 2017 11:36 pm
No new posts DDNAME parameter mistah kurtz JCL & VSAM 6 Mon Dec 19, 2016 4:41 pm
No new posts Execessive parameter issue Sumeendar JCL & VSAM 5 Mon Dec 19, 2016 4:35 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm


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