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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to enter ingle or double quotes in INSERT INTO ... VALUES?

Re: How to enter ingle or double quotes in INSERT INTO ... VALUES?

From: MaG <antonio_homepage_at_yahoo.com>
Date: 28 Apr 2003 17:42:36 -0700
Message-ID: <b50d7a74.0304281642.3963fd13@posting.google.com>


Anton,

Thanks for your help. Your suggestions will definitely work for my assignment.

I'm also wondering if there's a way to avoid typing two single quotes when you want to insert a single quote in the column.

For instance, to insert:
That's OK
in a varchar2 column, I have to type in: That''s OK

Is there any way I can avoid writing two quotes?

Thanks,
AH

"Anton Buijs" <remove_aammbuijs_at_xs4all.nl> wrote in message news:<3ea99abe$0$49107$e4fe514c_at_news.xs4all.nl>...
> MaG <antonio_homepage_at_yahoo.com> schreef in berichtnieuws
> b50d7a74.0304251122.cbcc4db_at_posting.google.com...
> | Hello,
> |
> | I need to write a script which asks the user to enter a string. This
> | string is stored in a varchar2 column. This can off course be achieved
> | using & in a INSERT INTO ... VALUES statement.
> |
> | But how do I handle input strings that contain single quotes and
> | double quotes?
> |
> | Thanks for your help,
> | AH
>
> SQL> create table test (col1 varchar2(10));
>
> Table created.
>
> SQL> insert into test values ('&param');
> Enter value for param: a
> old 1: insert into test values ('&param')
> new 1: insert into test values ('a')
>
> 1 row created.
>
> SQL> undef param
> SQL> /
> Enter value for param: "b"
> old 1: insert into test values ('&param')
> new 1: insert into test values ('"b"')
>
> 1 row created.
>
> SQL> undef param
> SQL> /
> Enter value for param: ''c''
> old 1: insert into test values ('&param')
> new 1: insert into test values ('''c''')
>
> 1 row created.
>
> SQL> select * from test;
>
> COL1
> ----------
> a
> "b"
> 'c'
>
> To be clear:
> b is added as double-quote b double-quote
> c is added as single-quote single-quote c single-quote single-quote
> Or: a double-quote can just be typed. A single-quote must be entered twice
> to get one into the column.
Received on Mon Apr 28 2003 - 19:42:36 CDT

Original text of this message

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