Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to escape single quotes
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
![]() |
![]() |