• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inserting | into oracle DB

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Michael
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Michael,
Can I use a BLOB field in a prepared statement ?
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic