Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: CLOB length problem

Re: CLOB length problem

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Mon, 2 Jun 2003 09:45:18 +0400
Message-ID: <bbeoa2$cvd$1@babylon.agtel.net>

"Charles Griswold" <cgriswold_at_attbi.com> wrote in message news:cZwCa.33288$M01.9627_at_sccrnsc02...
> I have a JDBC-Oracle app that reads and writes XML streams to CLOBs. For
> both reading and writing, I use a preparedstatement to get a Clob object and
> use either a stream reader or writer to access the xml data. In the
> situation where I shorten the XML stream and update the CLOB, the next time
> I read in the XML stream it has data from a previous update on the end of
> the XML stream. I was expecting the CLOB to remember the length of the last
> time it was written
> Has anyone had a similar experience? Do you have to manage the length
> yourself?

If you think a bit about it, it will be clear that this is expected behavior. The same will happen if you will use a file stream in this fashion:

  1. open an *existing* file of, say, 1000 bytes.
  2. write 500 bytes from position 0 to it
  3. flush and close the file

You will end up with 1000-byte file with its first half overwritten by your update, not with 500-byte file.

To *replace* a CLOB, you either need to trim it to zero length and then write it, or create a new empty CLOB, write it and then update the table with it.

-- 
Vladimir Zakharychev (bob@dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.
Received on Mon Jun 02 2003 - 00:45:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US