Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1093
  • Last Modified:

How to insert > 4000 char to clob in oracle

I am trying to insert a row of a string of more than 4000 characters in
clob datatype field using java program and it gives the following error
ORA-01704: string literal too long. I knew the solution is to use storedprocedure to insert the data. With this way, i need to make a lot of changes in the program. So, would like to check can i declare the field size for clob something like DB2?
1 Solution
can you provide java part of your code doing the insert..
chinswAuthor Commented:
I just do the normal insert as below:

 db.addBatchSql( "Insert into MM002 (P9_MM002_EREC_KEY, F9_MM002_CRE_TMS, FX_MM002_RCV_MSG_VER, FX_MM002_RCV_MSG_ID,FX_MM002_MERCHEQ_XML) " +
 "values ("+recKey+", "+recvTimeStamp+", '"+xmlvalidator.getVersion()+"', '"+xmlvalidator.getMsgId()+"', '"+xmlMsg+"')" );

FX_MM002_MERCHEQ_XML is a clob field in oracle and xmlMsg is String data type in Java
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

chinswAuthor Commented:
I can't use the oracle.jdbc because i need to make my application generic to support different database platform (oracle/db2). Any way to solve this problem?
Use PreparedStatement.setCharacterStream
Please make sure that you data type is CLOB because 4000 characters is a limit size of VARCHAR2
Kevin CrossChief Technology OfficerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now