Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CLOB insertion in Oracle DB using Java

6 views
Skip to first unread message

US

unread,
May 17, 2000, 3:00:00 AM5/17/00
to
Hi all Java-Database experts,

I need to insert a large field inside a clob (oracle DB), but I keep getting
the following error:
java.io.IOException: ORA-22920: row containing the LOB value is not locked
ORA-06512: at "SYS.DBMS_LOB", line 708
ORA-06512: at line 1

at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:477)
at
oracle.jdbc.driver.OracleClobWriter.flushBuffer(OracleClobWriter.java:181)
at oracle.jdbc.driver.OracleClobWriter.write(OracleClobWriter.java,
Compiled Code)
at java.io.Writer.write(Writer.java:108)
at t10.main(t10.java, Compiled Code)


I have no clue what is causing this... help....
I would greatly appreciate any help or tip.

This is the program which generated this error:

Statement stmt = conn.createStatement ();
String cmd="CREATE TABLE my_crap_table (x varchar2(5), c clob)";
stmt.execute(cmd);
stmt.execute("INSERT INTO my_crap_table VALUES('ABCD',empty_clob())");
cmd="SELECT * FROM my_crap_table WHERE X='ABCD'";
ResultSet ret=stmt.executeQuery(cmd);
ret.next();
CLOB clob=((OracleResultSet)ret).getCLOB(2);
int size=clob.getBufferSize();
char[] buffer=new char[size];
int length=-1;

Writer outstream=clob.getCharacterOutputStream();
while ((length=in.read(buffer))!=-1)
outstream.write(buffer);

in.close();
outstream.close();

US

Bart LEBOEUF

unread,
May 18, 2000, 3:00:00 AM5/18/00
to
Hi,

The problem is, you insert a lob data in a record that is not locked.
You must lock this record before the insert operation.
To lock the record make a select query with "FOR UPDATE" parameter.
example : SELECT * FROM my_crap_table WHERE X='ABCD' FOR UPDATE

I hope it help you.

Bart

bart.vcf
0 new messages