• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

an example to insert data into Oracle Clob

 
Greenhorn
Posts: 15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For theory backgroud:
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oralob.htm#1000888
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
Example:

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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Sheriff
Posts: 3837
66
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)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic