Skip to Main Content
  • Questions
  • inserting data values with puctuation like single quote character

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Sing.

Asked: July 12, 2000 - 4:45 pm UTC

Last updated: July 12, 2000 - 4:45 pm UTC

Version: 8.0.6

Viewed 1000+ times

You Asked

Tom,

I have a table xyz that has columns
c1 - number
c2 varchar(8)

How can I insert data values 1 and O'Brian in the
fields c1 and c2 respectively?

Thanks
S

and Tom said...

The best answer is: use bind variables. Bind variable are SO important.

You would prepare (in whatever language you are using) a statement like:

insert into xyz (c1, c2) values ( :c1, :c2 );


You would execute this statement over and over with different BIND values. Now, you don't have to compile the statement each time, we use shared sql, and your program runs inserts maybe 10 times faster.....

If you tell me your language, I can probably find an example of binding for you.


If you don't like that advice (and believe -- its really IMPORTANT to use bind variables), you can:

insert into xyz (c1, c2 ) values ( 1023, 'O''Brian' );

2 quotes = 1 quote in a quoted string.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

inserting data values with puctuation like single quote character

Segun Jeks, November 23, 2005 - 4:32 am UTC

Very helpful in handling where clauses which tend to filter for value like O'SHEA.