Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: how to escape single quotes

Re: how to escape single quotes

From: QuestionExchange <USENET_at_questionexchange.com>
Date: 12 Oct 1999 11:23:28 GMT
Message-ID: <1570qx@questionexchange.com>


> Hi,
>
> How do I guard against single quotes in text messing up my
SQL
> statements. For example, I have some text like:
>
> 'this is some text. It's got an apostrophe in it'
>
> ie there's inadvertantly 3 single quotes there, which ruin
the SQL
> statement. I could URL-encode the text first and URL-decode
it
> afterwards (using PHP), but is there a 'proper' way to encode
it (in
> Oracle 8)?

Hi,
The answer is: you have to put 2 adjacent single quotes within your text. Thus:
'this is some text. It''s got an apostrophe in it' By the way, this is written in the Oracle SQL reference. I hope this helps.

--
  This answer is courtesy of QuestionExchange.com   http://www.questionexchange.com/showUsenetGuest.jhtml?ans_id=5125&cus_id=USENET&qtn_id=3657 Received on Tue Oct 12 1999 - 06:23:28 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US