title: How to handle a single quote in Oracle SQL?
body: <p>I have a query constructed in Java to search and fetch records,when constructing with the values <strong>'</strong> (<strong>Single Quote</strong>)(For Example:<strong>New's</strong>) then I'm not getting any results.</p>
  
  <p>Here is the query where I am setting the value <strong>New's</strong>:</p>
  
  <pre><code>SELECT COUNT(1) FROM AGX_THERAPEUTIC_AREA T WHERE  UPPER(T.THERAPEUTIC_NAME) LIKE ? ESCAPE \  OR  UPPER(T.THERAPEUTIC_AREA_DESC) LIKE ? ESCAPE \ 
      bind =&gt; [NEW'S%, NEW'S%]
  </code></pre>
  
  <p>Here is the method in which i am handling single quote:</p>
  
  <pre><code>public static String handleSingleQuote(String searchString) {
          if ((searchString == null) || searchString.trim().equals("")) {
              searchString = "";
          }
  
          searchString = searchString.trim();
  
          int length = searchString.length();
          StringBuffer searchBuffer = new StringBuffer();
  
          for (int index = 0; index &lt; length; index++) {
              if (searchString.charAt(index) == '\'') {
                  searchBuffer.append("''");
              } else {
                  searchBuffer.append(searchString.charAt(index));
              }
          } // end of for loop
  
          searchString = searchBuffer.toString();
  
          return (searchString);
      } 
  </code></pre>