Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Inserting values that have single quotes
A copy of this was sent to Don Pendergast III <pendergd_at_ohiou.edu>
(if that email address didn't require changing)
On Wed, 24 Mar 1999 13:49:45 GMT, you wrote:
>Hi There!
>
>A single quote is the only way to delimit character string
>constants. Therefore, other than having two single quotes within
>the character string in order to represent one single quote is there
>any other way to enter items into the database that have a single
>quote in the text (in SQL)?
>
>For example, in order to input a last name of O'CONNOR into
>a table you would have to have:
>INSERT INTO TABLE1 VALUES ('O''CONNOR')
>
>is there any other way to put this value into the database without
>having to add the extra single quote in the name?
>
>Any help at all is much appreciated!
>
Use bind variables in your program instead of constants (much better performance will be another side effect).
For example:
insert into table1 values ( :x );
instead of
insert into table1 values ( 'O''CONNOR' );
you would bind the character string O'CONNOR to :x and execute the insert then. Methods vary by language....
>Don Pendergast
>pendergd_at_ohiou.edu
>
>Web Analyst/Programmer
>Ohio University
>
>
>
>
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities