Apostrophe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Apostrophe

    Can anyone tell me why an word with an apostrophe cannot be saved to the db?

    i get this error

    Incorrect syntax near 's'.
    Unclosed quotation mark after the character string ')'.

    got some textboxes on a web form. and i encountered this error when i tried to save for example, sweet's ??

    is there a solution for it ?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by OuTCasT
    Can anyone tell me why an word with an apostrophe cannot be saved to the db?

    i get this error

    Incorrect syntax near 's'.
    Unclosed quotation mark after the character string ')'.

    got some textboxes on a web form. and i encountered this error when i tried to save for example, sweet's ??

    is there a solution for it ?

    Because a single quote is signifies string constant. If you want it stored that way, you might want to handle that. Depending on your requirement, you can either replace it with '' (two single quotes) or a double quote ("). If you're doing the double quote, you have to handle it back to a (one) single quote when you retrieve it back for your front-end.

    Happy Coding.

    -- CK

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Originally posted by ck9663
      Because a single quote is signifies string constant. If you want it stored that way, you might want to handle that. Depending on your requirement, you can either replace it with '' (two single quotes) or a double quote ("). If you're doing the double quote, you have to handle it back to a (one) single quote when you retrieve it back for your front-end.

      Happy Coding.

      -- CK
      I did read about that -- CK
      replace ("" ' "") or something like that.

      things can never just be straight forward now can they.

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Originally posted by OuTCasT
        I did read about that -- CK
        replace ("" ' "") or something like that.

        things can never just be straight forward now can they.
        Why are you not able to replace a single quote with a two single quotes

        Check this:

        [code=sql]

        1* SELECT REPLACE('Your'' s','''','''')
        SQL> /

        REPLAC
        ------
        Your's

        SQL> ed
        Wrote file afiedt.buf

        1* SELECT REPLACE('Your'' s','''','''''')
        SQL> /

        REPLACE
        -------
        Your''s

        SQL>

        [/code]

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          Originally posted by OuTCasT
          I did read about that -- CK
          replace ("" ' "") or something like that.

          things can never just be straight forward now can they.
          Yep.

          The more they things get simple, the more they get complicated ;)

          -- CK

          Comment

          Working...