aspose file tools*
The moose likes JDBC and the fly likes Question on update CLOB column when the column value is null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Question on update CLOB column when the column value is null" Watch "Question on update CLOB column when the column value is null" New topic
Author

Question on update CLOB column when the column value is null

Yishu Liu
Greenhorn

Joined: Jan 23, 2004
Posts: 6
Hi all,

I have a Oracle database table column that is a CLOB column. I have a program that updates individual records of this table. For the CLOB column, I use the following steps to update the column value:
1. Use "Select...for update" statement to select the row.
2. Use getClob() method on the ResultSet to get the locator and cast the Clob locator to oracle.sql.Clob.
3. Get the outputstream of this Clob locator and write the data.

The problem is that getClob() returns null when the column is null. Of all the examples I've seen so far, the CLOB clumn either contains value or is already initialized to empty_clob. One way I can think of to work around the problem is that if getClob() returns null, I use an update statement to set the CLOB field to empty_clob and then repeat the steps I listed above. But it's kind of clumsy. I would very much appreciate some inputs on a better approach.

Many Thanks!

Yishui
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on update CLOB column when the column value is null