If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Escape delimiter in select query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-07, 02:10
sh_kk sh_kk is offline
Registered User
 
Join Date: Sep 2007
Posts: 7
Escape delimiter in select query

Hi All,
Need your help on this query... The query is as follows :

select nm_ctrl_cd from temp where locate('*',translate( nm_ctrl_cd , '*******************************', '~!@#$%^&*()_+}{":?><`-=]['' /., ;' )) > 0


When i execute this query , i am getting the following error:

"SQL0010N The string constant beginning with "' )) > 0
" does not
have an ending string delimiter."


Now this is certainly bcoz of the delimiter.. So the point is that i need to know how to escape a delimiter..

Please help me out with this as i need to fix an issue.

-Thanks
Reply With Quote
  #2 (permalink)  
Old 09-17-07, 03:32
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Use two consecutive single quotes to replace one single quote.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 09-17-07, 10:45
jsharon1248 jsharon1248 is offline
Registered User
 
Join Date: Apr 2007
Location: Chicago
Posts: 57
You didn't specify which version you're using, so I don't know if you're using ASCII or EBCDIC. What you can do is concat the ';' character as a hex string. I think I have the right value for ASCII in this example:

Code:
select col1 from tbl1
where locate('*',translate( col1 
, '*******************************'
, '~!@#$%^&*()_+}{":?><`-=]['' /., ' || x'59' )) > 0;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On