How to append text to an oracle clob
Is it possible to append text to an oracle 9i clob without rereading and rewriting the whole content?
I have tried this:
PreparedStatement stmt = cnt.prepareStatement(
"select OUT from QRTZ_JOBEXEC where EXEC_ID=? "
+ "for update",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.C开发者_StackOverflowONCUR_UPDATABLE);
try {
stmt.setLong(1, id);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
Clob clob = rs.getClob(1);
long len = clob.length();
Writer writer = clob.setCharacterStream(len+1);
try {
PrintWriter out = new PrintWriter(writer);
out.println(line);
out.close();
} finally {
writer.close();
}
rs.updateClob(1, clob);
rs.updateRow();
}
rs.close();
} finally {
stmt.close();
}
But I'm getting an "Unsupported feature" exception on the call to setCharacterStream.
DBMS_LOB.APPEND is the key.
if you are just adding text then you could try a simple
UPDATE qrtz_jobexec SET out = out || ? WHERE exex_id=?
精彩评论