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: Rudy Zung <zungr_at__SPAMFODDER_prographsystems.com>
Date: 29 Sep 1999 13:03:31 -0400
Message-ID: <ud7v1vee4.fsf@_SPAMFODDER_prographsystems.com>


kev <kevin.porter_at_fast.no> writes:

> 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)?
>
> tia,
>
> - Kev

Use either TRANSLATE or REPLACE (I usually get those two confused with each other until I get to the documentation) to convert each single occurance of a single quote into two occurances of a single quote; the will render your string as:

   this is some text. It''s got an apostrophe in it

Same semantics as Pascal string quoting.

...Ru Received on Wed Sep 29 1999 - 12:03:31 CDT

Original text of this message

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