Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:50:27+00:00 2026-05-26T22:50:27+00:00

I know it works by using SQL update activity set REFERENCE = EMPTY_CLOB() where

  • 0

I know it works by using SQL

update activity set REFERENCE = EMPTY_CLOB() where id = ?

But I cannot do like this, I cannot hard coded ‘EMPTY_CLOB()’ in SQL.
I used the way like the following:

String empty_string = "";
conn = getConnection();

pStmt = conn.prepareStatement("SELECT REFERENCE FROM activity WHERE ID = ? FOR UPDATE");
pStmt.setLong(1, 1);
rset = pStmt.executeQuery();
Clob clob = null;
while (rset.next()) {
    clob = rset.getClob(1);
    Writer writer = adapter.getCharacterOutputStream(clob);
    writer.write(empty_string);         
    writer.flush();
    writer.close();
}

pStmt = conn.prepareStatement("update activity set REFERENCE = ? WHERE ID = ?");
pStmt.setClob(1, clob);
pStmt.setLong(2, 1);
pStmt.executeUpdate();

But It didn’t work. the clob didn’t be updated to empty string, it still stored as previous value.

Any body can help me on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:50:27+00:00Added an answer on May 26, 2026 at 10:50 pm

    As I have already mentionued in your other question: in my experience getClob() and setClob() don’t work properly.

    Use setCharacterStream() instead:

    StringReader clob = new StringReader("");
    pStmt = conn.prepareStatement("update activity set REFERENCE = ? WHERE ID = ?");
    pStmt.setCharacterStream(1, clob, 0);
    pStmt.setLong(2, 1);
    pStmt.executeUpdate();
    

    That way you can also remove the unnecessary SELECT before updating, which will improve performance as well.

    Another option would be to simply set that column to NULL

    Edit:

    With newer drivers (11.x) you might also want to try to use setString() and getString() on the CLOB column.

    The locking of the row should only be necessary when you use a LOB locator that you intend to keep during a transaction that spans more than one statement (at least that’s my understanding of the linked reference to the manual).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code I'm using to update an SQL database: Public Sub main()
I have this sql: UPDATE JOBMAKE SET WIP_STATUS='10sched1' WHERE JBT_TYPE IN (SELECT JBT_TYPE FROM
I'm using SQL Server 2008 and would like to know if there is a
Does anyone know if the LIMIT and OFFSET clause work when using the UPDATE
I know how to make the intellisense work in a .js file using this
I like to know how works or what means(?) when you define a function
I'm trying to understand how this exactly works (I know what it does, I
I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
Using SQL Server 2008. This is a really junior question and I could really
Firstly, this DB question could be a bit DB agnostic, but I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.