Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to enter ingle or double quotes in INSERT INTO ... VALUES?
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 ('¶m');
Enter value for param: a
old 1: insert into test values ('¶m')
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 ('¶m')
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 ('¶m')
new 1: insert into test values ('''c''')
1 row created.
SQL> select * from test;
COL1
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
![]() |
![]() |