• Post Reply Bookmark Topic Watch Topic
  • New Topic

Insert with '

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How can I insert a string with ' into a table in DB2?
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Yu:
Hi,
How can I insert a string with ' into a table in DB2?

Use a PreparedStatement ( setString() method ) and it will take care of it for you. If you need to use a statement you have to create a routine that escapes it with the DB2 escape character. Assuming it is 2 single quotes, this routine would work for you:

Jamie
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!