title: Insert CLOB into Oracle database
body: <p><strong>My question is:</strong> How do you get around the <code>ORA-01704: string literal too long</code> error when inserting (or doing anything in queries) with <code>CLOB</code>s?</p>
  
  <p>I want to have a query like this:</p>
  
  <pre><code>INSERT ALL
     INTO mytable VALUES ('clob1')
     INTO mytable VALUES ('clob2') --some of these clobs are more than 4000 characters...
     INTO mytable VALUES ('clob3')
  SELECT * FROM dual;
  </code></pre>
  
  <p>When I try it with actual values though I get <code>ORA-01704: string literal too long</code> back. This is pretty obvious, but how do I insert clobs (or execute any statement at all with a clob)?</p>
  
  <p>I've tried looking at this <a href="https://stackoverflow.com/questions/5549450">question</a>, but I don't think it has what I'm looking for. The clobs I have are in a <code>List&lt;String&gt;</code> and I iterate through them to make the statement. My code as it is follows:</p>
  
  <pre><code>private void insertQueries(String tempTableName) throws FileNotFoundException, DataException, SQLException, IOException {
  String preQuery = "  into " + tempTableName + " values ('";
  String postQuery = "')" + StringHelper.newline;
  StringBuilder inserts = new StringBuilder("insert all" + StringHelper.newline);
  List&lt;String&gt; readQueries = getDomoQueries();
  for (String query : readQueries) {
    inserts.append(preQuery).append(query).append(postQuery);
  }
  inserts.append("select * from dual;");
  
  DatabaseController.getInstance().executeQuery(databaseConnectionURL, inserts.toString());
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public ResultSet executeQuery(String connection, String query) throws DataException, SQLException {
    Connection conn = ConnectionPool.getInstance().get(connection);
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    conn.commit();
    ConnectionPool.getInstance().release(conn);
    return rs;
  }
  </code></pre>