我的问题是:当插入(或在查询中进行任何操作)CLOB
时,如何解决ORA-01704:字符串文字太长
错误?
我希望有一个像这样的查询:
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;
当我使用实际值时,我收到了
ORA-01704:字符串文字太长
的反馈。这很明显,但是我该如何插入clobs(或使用clob执行任何语句)?我尝试查看这个问题,但我不认为它有我要找的内容。我拥有的clobs在一个
List<String>
中,我遍历它们以创建语句。我的代码如下: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<String> readQueries = getDomoQueries();
for (String query : readQueries) {
inserts.append(preQuery).append(query).append(postQuery);
}
inserts.append("select * from dual;");
DatabaseController.getInstance().executeQuery(databaseConnectionURL, inserts.toString());
}
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;
}
PreparedStatement
及其setClob()
方法,而不是动态SQL和构建带有字符串字面量的插入语句? - QuantumMechanic