Where's my invalid character (ORA-00911)
If you use the string literal exactly as you have shown us, the problem is the ;
character at the end. You may not include that in the query string in the JDBC calls.
As you are inserting only a single row, a regular INSERT
should be just fine even when inserting multiple rows. Using a batched statement is probable more efficient anywy. No need for INSERT ALL
. Additionally you don't need the temporary clob and all that. You can simplify your method to something like this (assuming I got the parameters right):
String query1 = "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'";String query2 = ".....";String sql = "insert into domo_queries (clob_column) values (?)";PreparedStatement pstmt = con.prepareStatement(sql);StringReader reader = new StringReader(query1);pstmt.setCharacterStream(1, reader, query1.length());pstmt.addBatch();reader = new StringReader(query2);pstmt.setCharacterStream(1, reader, query2.length());pstmt.addBatch();pstmt.executeBatch(); con.commit();
Of the top of my head, can you try to use the 'q' operator for the string literal
something like
insert all into domo_queries values (q'[select substr(to_char(max_data),1,4) as year,substr(to_char(max_data),5,6) as month,max_datafrom dss_fin_user.acq_dashboard_src_load_successwhere source = 'CHQ PeopleSoft FS']')select * from dual;
Note that the single quotes of your predicate are not escaped, and the string sits between q'[...]'.
One of the reason may be if any one of table column have an underscore(_) in its name . That is considered as invalid characters by the JDBC . Rename the column by a ALTER Command and change in your code SQL , that will fix .