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)?
There are several ways to do it, but i think quoting it with a single tick is the easiest.
Like:
SQL> desc test
Name Null? Type ------------------------------- -------- ---- TEST VARCHAR2(20)
SQL> insert into test values ('I''m inserting this');
1 row created.
SQL> select * from test;
TEST
--
Ove
Received on Wed Sep 29 1999 - 18:20:39 CDT
![]() |
![]() |