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: Anton Buijs <remove_aammbuijs_at_xs4all.nl>
Date: Fri, 25 Apr 2003 22:29:58 +0200
Message-ID: <3ea99abe$0$49107$e4fe514c@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 Fri Apr 25 2003 - 15:29:58 CDT

Original text of this message

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