In Oracle OCCI/OCI, should buffer for reading LOBs be larger than actual data? Getting ORA-32116 In Oracle OCCI/OCI, should buffer for reading LOBs be larger than actual data? Getting ORA-32116 oracle oracle

In Oracle OCCI/OCI, should buffer for reading LOBs be larger than actual data? Getting ORA-32116


I suspect that you've got multi-byte characters in your CLOB.

According to the documentation clob.length() "returns the number of characters in the CLOB" whereas the buffsize parameter of clob.read() states that "valid values are numbers greater or equal to amt", which in turn says that it's "the number of bytes to be read."

In other words (and according to the documentation) you're passing the number of characters to clob.read() when it's expecting the number of bytes. The fact that you're getting an error would suggest that the former is smaller than the latter.

The documentation suggests changing the buffer to be a utext, after setting the character set via setCharSetId() would fix it.

Alternatively, if you've got multi-byte characters and don't need to do any character representation (no idea), it might be worth working with BLOBs instead; blob.length() returns the number of bytes.