Select the data with '

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swapnam
    New Member
    • Feb 2008
    • 1

    Select the data with '

    Hi,

    I have a problem using the select query to retreive the data containing '. I am using Aqua data studio as my DB2 client and my server is DB2 8.1.

    For example,

    select * from PLAN where plan_name = 'A''

    I am selecting for a plan whose plan name is A'. I was able to insert this data using my java code.

    When I am executing this query, I get the following error,

    DB2 SQL error: SQLCODE: -10, SQLSTATE: 42603, SQLERRMC: 'A''
    Message: The string constant beginning with "'A''" does not have an ending string delimiter

    Please help to retreive this data.
  • docdiesel
    Recognized Expert Contributor
    • Aug 2007
    • 297

    #2
    Hi,

    usually you've got to escape the apostrophe ' with a second one, so use a

    Code:
    select * from PLAN where plan_name = 'A'''
    with three apostrophes after the A. Yes, I know, it looks strange, but it works.

    Regards,

    Bernd

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      That single quote is a night mare for developers. If not handled properly that appears time and again and at times can crash the entire application.

      Comment

      Working...