• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Escape single quotes

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends

I have a cursor which reads columns FirstName and LastName from table A into 2 variables which is then used to insert their values in Table 2. The insert statement is first constructed as a String. Unfortunately some of these values have a single-quote already in them; hence string construction surrounded by single-quotes fails for certain records. Double-quotes does not work either.

Is there any workaround to escape single-quotes in the names values?

Thanks
Sandeep

PS: Google could not provide much details either...I am sure my keywords were not right...:-(
 
Sandeep Advani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind - I got it using the Oracle replace function.
Replaced single quotes with double.
 
author & internet detective
Posts: 39435
768
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Also a PreparedStatement will handle the escaping for you if going through JDBC.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!