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

Home -> Community -> Usenet -> c.d.o.misc -> Re: On insert, what characters do I need to escape? (or do I?)

Re: On insert, what characters do I need to escape? (or do I?)

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Fri, 21 May 1999 12:02:51 GMT
Message-ID: <37454964.81896871@inet16.us.oracle.com>


On Thu, 20 May 1999 18:23:52 GMT, brian_at_brie.com (Brian Lavender) wrote:

>When I do an sql insert
>insert into foo values (35.3,'tommy',null,''','!@#$><-'',null);
> ^ how do I treat this?

To insert a ' you can escape it with a second '. So to insert a ' you can do the following...

Given

SQL> desc t              
 Name                            Null?    Type
 ------------------------------- -------- ----
 ID                                       NUMBER
 VAL                                      VARCHAR2(100)

SQL> insert into t ( id, val ) values ( 1, '''' ); 1 row created.

SQL> select * from t;

        ID VAL
---------- ----------

         1 '

To insert two ', use this ...

SQL> insert into t ( id, val ) values ( 2, '''''' ); 1 row created.

SQL> select * from t;

        ID VAL
---------- ----------

         1 '
         2 ''



hope this helps.

chris.

>
>I guess I have to at least escape the single quotation mark. Do I do
>that with a backslash? What about other characters? Do I need to give
>them special treament?
>
>brian
>--------------------
>Brian Lavender
>Sacramento, CA
>http://www.brie.com/brian/
>
>"If a train station is where the train stops,
>what is a workstation?" -- Phil Adamson

--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri May 21 1999 - 07:02:51 CDT

Original text of this message

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