This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Question on update CLOB column when the column value is null
 
Similar Threads
Blob Clob
unable to update CLOB data using Commons DBCP connection.
Writing a Clob in Java
JDBC Update example using empty_clob() function
help: lock problem during Clob update