• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

an example to insert data into Oracle Clob

Posts: 15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For theory backgroud:
Step1. Insert empty_clob() into the Clob column of Oracle
Step2. Set autocommit to false
Step3. Select Clob as oracle.sql.CLOB from database
Step4. Insert String into Clob
Step5. Commit

I use Oracle 9i and Java 1.4, JDBC 9i, friend also test above code on Oracle 8i with Java 1.2, hope this helps.
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
Posts: 3837
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note that this was posted many years ago. The procedure is still valid in newer Oracle versions, though it could use a few modifications:

1) Step two should come first. This way it is commiting the insert of an empty clob. Depending on other circumstances, that might not hurt, but since the intent is to insert a populated clob, it should all happen in one transaction. (The code does it this way actually, only the summary is wrong.)

2) I'd emphasize the need to select for update in step three (again, it is done in the code, but not mentioned in the summary). However, when it actually is just one transaction, the select for update is not needed, as the row is already locked (but it doesn't hurt).

Oracle's own documentation is also a good source if you need to clear more doubts about Oracle's LOBs.
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
    Bookmark Topic Watch Topic
  • New Topic