Re: Inserting a ' in a VARCHAR

From: Chris Hamilton <toneczar_at_bellatlantic.net>
Date: 2000/06/07
Message-ID: <393eb0c1.21840665_at_news.erols.com>#1/1


[Quoted] On Wed, 07 Jun 2000 19:59:11 GMT, "Joe Patterson" <jpatterson_at_elitra.com> wrote:

>How does one include a ' (single quote, apostrphy) directly into a VARCHAR?
>Is there a way to escape the quote like \' or something? I want to avoid
>converting the ' to a work like prime or apostrophy.
>
>Anyone know how to do this?

I think an easy way is to convert it to a ASCII code function. The Oracle CHR() function can accomplish this when fed the required ASCII value.

For instance,

SQL> select chr(39) from dual;

C
-
'

So, you could do this:

insert into table_x
(col_1)
values
('My name is Troy O' || chr(39) || 'Leary');

SQL> select * from table_x;

COL_1



My name is Troy O'Leary

Chris Received on Wed Jun 07 2000 - 00:00:00 CEST

Original text of this message