开发者

How to append text to an oracle clob

开发者 https://www.devze.com 2023-03-23 22:29 出处:网络
Is it possible to append text to an oracle 9i clob without rereading and rewriting the whole content?

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=?
0

精彩评论

暂无评论...
验证码 换一张
取 消