my dog learned polymorphism*
The moose likes JDBC and the fly likes Inserting | into oracle DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Inserting | into oracle DB" Watch "Inserting | into oracle DB" New topic
Author

Inserting | into oracle DB

steph rinert
Greenhorn

Joined: Oct 31, 2002
Posts: 7
I am inserting some values into an oracle DB and the following error does not allow me to insert the data ***java.sql.SQLException: ORA-00996: the concatenate operator is ||, not |***
The data that i am inserting does contain numerous single | (pipes) and i am using a generic "insert into (table) values (" + vector (contains many columns) + ")";

Thank you
steph rinert
Greenhorn

Joined: Oct 31, 2002
Posts: 7
and I believe the problem is that my data is not wrapped with single quotes since its in a vector, if so, then how would i wrap each column in single quoutes in the vector before I use it in the insert statement.
Thanks
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Instead of trying to build a single SQL statement into a String, it is better to use a prepared statement. That way, you don't have to worry about special characters such as | and '

This will work as long as the String returned by myVector.toString() is short enough to fit into the database column.
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Dear Michael


humanum errare est.
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Dear Michael,
Can I use a BLOB field in a prepared statement ?
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Originally posted by achana chan:
Dear Michael,
Can I use a BLOB field in a prepared statement ?

Probably. But it might not be as easy as you think. A Blob must first be fetched from the database. Then you can fill it with byte[] s, and set it back.
It depends on your database driver and database.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inserting | into oracle DB