title: Where's my invalid character (ORA-00911)
body: <p>I'm trying to insert <code>CLOB</code>s into a database (see <a href="https://stackoverflow.com/questions/10727521/">related question</a>). I can't quite figure out what's wrong. I have a list of about 85 clobs I want to insert into a table. Even when inserting only the first clob I get <code>ORA-00911: invalid character</code>. I can't figure out how to get the statement out of the <code>PreparedStatement</code> before it executes, so I can't be 100% certain that it's right, but if I got it right, then it should look exactly like this:</p>
  
  <pre><code>insert all
    into domo_queries values ('select 
  substr(to_char(max_data),1,4) as year,
  substr(to_char(max_data),5,6) as month,
  max_data
  from dss_fin_user.acq_dashboard_src_load_success
  where source = ''CHQ PeopleSoft FS''')
  select * from dual;
  </code></pre>
  
  <p>Ultimately, this <a href="http://www.techonthenet.com/oracle/questions/insert_rows.php" rel="noreferrer"><code>insert all</code></a> statement would have a lot of <code>into</code>'s, which is why I just don't do a regular <code>insert</code> statement. I don't see an invalid character in there, do you? (Oh, and that code above <strong>runs fine when I run it in my sql developer tool</strong>.) And I if I remove the semi-colon in the <code>PreparedStatement</code>, it throws an <code>ORA-00933: SQL command not properly ended</code> error.</p>
  
  <p>In any case, here's my code for executing the query (and the values of the variables for the example above).</p>
  
  <pre><code>public ResultSet executeQuery(String connection, String query, QueryParameter... params) throws DataException, SQLException {
    // query at this point = "insert all
                            //into domo_queries values (?)
                            //select * from dual;"
    Connection conn = ConnectionPool.getInstance().get(connection);
    PreparedStatement pstmt = conn.prepareStatement(query);
    for (int i = 1; i &lt;= params.length; i++) {
      QueryParameter param = params[i - 1];
      switch (param.getType()) { //The type in the example is QueryParameter.CLOB
        case QueryParameter.CLOB:
          Clob clob = CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_SESSION);
          clob.setString(i, "'" + param.getValue() + "'");
          //the value of param.getValue() at this point is:
          /*
           * select 
           * substr(to_char(max_data),1,4) as year,
           * substr(to_char(max_data),5,6) as month,
           * max_data
           * from dss_fin_user.acq_dashboard_src_load_success
           * where source = ''CHQ PeopleSoft FS''
           */
          pstmt.setClob(i, clob);
          break;
        case QueryParameter.STRING:
          pstmt.setString(i, "'" + param.getValue() + "'");
          break;
      }
    }
    ResultSet rs = pstmt.executeQuery(); //Obviously, this is where the error is thrown
    conn.commit();
    ConnectionPool.getInstance().release(conn);
    return rs;
  }
  </code></pre>
  
  <p>Is there anything I'm just missing big time?</p>