How to insert values that have quote?


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?



Ans:
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....
 
 

Hosted by www.Geocities.ws

1