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 > Find Strings which Contain Double Quotes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 12:47
SDyke SDyke is offline
Registered User
 
Join Date: Aug 2009
Posts: 14
Find Strings which Contain Double Quotes

I need help with db2 sql syntax that uses posstr to find string taht contain double quotes. The following gives syntax error.

testconnString = "Select * From amflib1.itemasa Where posstr(itdsc, '""') > 0"
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 14:29
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Strings in DB2 sould enclosed with single quotations.

Please try ...
testconnString = 'Select * From amflib1.itemasa Where posstr(itdsc, ''"'') > 0'
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 14:34
SDyke SDyke is offline
Registered User
 
Join Date: Aug 2009
Posts: 14
Still get syntax error
Reply With Quote
  #4 (permalink)  
Old 01-05-12, 15:07
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
What was the exact error message(s)?

You might want to assign a string to a variable testconnString. But it is not meet a syntax of DB2 SQL.

DB2 syntax is
Code:
Syntax

>>-SET---------------------------------------------------------->

     .-,------------------------------------------------------------------.     
     V                                                                    |     
>--+---+-| target-variable |--=--+-expression-+-------------------------+-+-+-><
   |   |                         +-NULL-------+                         |   |   
   |   |                         '-DEFAULT----'                         |   |   
   |   |    .-,-------------------.             .-,--------------.      |   |   
   |   |    V                     |             V                |      |   |   
   |   '-(----| target-variable |-+--)--=--+-(----+-expression-+-+--)-+-'   |   
   |                                       |      +-NULL-------+      |     |   
   |                                       |      '-DEFAULT----'      |     |   
   |                                       '-(--row-fullselect--)-----'     |   
   +-boolean-variable-name--=--+-search-condition-+-------------------------+   
   |                           +-TRUE-------------+                         |   
   |                           +-FALSE------------+                         |   
   |                           '-NULL-------------'                         |   
   +-array-variable-name--[--array-index--]--=--+-expression-+--------------+   
   |                                            '-NULL-------'              |   
   +-target-cursor-variable--=--+-cursor-variable-name---------+------------+   
   |                            +-| cursor-value-constructor |-+            |   
   |                            '-NULL-------------------------'            |   
   |                                  .-,--------------.                    |   
   |                                  V                |                    |   
   '-| target-row-variable |--=--+-(----+-expression-+-+--)-+---------------'   
                                 |      '-NULL-------'      |                   
                                 +-(--row-fullselect--)-----+                   
                                 +-row-expression-----------+                   
                                 '-NULL---------------------'
See more detailes in
SET variable - IBM DB2 9.7 for Linux, UNIX, and Windows
Reply With Quote
  #5 (permalink)  
Old 01-05-12, 20:55
fengsun2 fengsun2 is offline
Registered User
 
Join Date: Nov 2011
Posts: 124
Maybe you can use chr() function to do this

testconnString = "Select * From amflib1.itemasa Where posstr(itdsc, chr(34)) > 0"
Reply With Quote
  #6 (permalink)  
Old 01-05-12, 22:34
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
SDyke,

Is the code in op extracted from other than an SQL routine(compound SQL, SQL function, or SQL procedure, so on)?

If so, I want to recommend you
to extract the select statement from your program and execute it independently,
and see exact error code/error text of the error message(s) you received.
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