How to INSERT a String that contains a single quote.

  • A string to be inserted contains a single quote which is a special character in Oracle SQL.
  • Example:
'King Mongkut's University of Technology North Bangkok'
INSERT INTO MyTABLE(Name) VALUES('King Mongkut's University of Technology North Bangkok');
  • Escape the single quote in the middle of string.
INSERT INTO MyTABLE(Name) VALUES('King Mongkut''s University of Technology North Bangkok');
  • Java code
if (myText.contains("'")) {
myText= myText.replace("'", "''");
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Static or dynamic libraries, here is the question

Can a DOLL replace a HUMAN? #shorts

Solving problems with PEDAC

How Programming Helped Me Change My Mindset!

Boolean logic

What is Swift?

Presenting: VeeDo

Building Reliable Systems

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SuperChai

SuperChai

More from Medium

Effective RCA

Nyck de Vries on ambition, intuition, and having the confidence to get where you want to go

Thoughts of a newly signed-up overthinker

Are you tired of schools teaching our kids irrelevant information using outdated methods?