Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Reading large large string from database


Former Community Member
I am reading is a large string value. It's data type in Oracle is CLOB. I was originally casting it to vARCHAR2(4000) in the select statement, but just realized the data can be larger than 4000. I took out the cast and have tried changing to several data types, but they all error out. How can I read in string data greater than 4000 characters?
6 Replies


Level 9
Use a String variable with unlimited length (there's a checkbox to control it when you define the string variable). In older versions, you can set the length to -1.




Former Community Member
It gave an error that it could not put a CLOB into a String.


Former Community Member
You must use Java to do this, the Execute Script operation makes it simple. I have put together a little process to demonstrate, and I can paste the Java from the Execute Script step below.

It's all in the data-typing. In the sample I built, the BigString and NewBigString process variables are of LiveCycle type "string" with unlimited size. These become CLOBs in the database. When read as a CLOB object using JDBC, converted to Java Strings, they then can be loaded into the LiveCycle Process data and the API handles the rest.

Let me know if I'm not clear enough with my explanation.

Jeff A Yates



import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.Statement;

import java.sql.ResultSet;

import javax.sql.DataSource;

import javax.naming.InitialContext;

int processId = patExecContext.getProcessDataIntValue("/process_data/@id");

InitialContext context = new InitialContext();

Connection connection = ((DataSource)context.lookup("java:/IDP_DS")).getConnection();

String queryQuery = "select bigdocument, bigstring from tb_pt_workwithxlobs where process_instance_id = ?";

PreparedStatement queryStatement = connection.prepareStatement(queryQuery);

try {

queryStatement.setInt(1, processId);

ResultSet results = queryStatement.executeQuery();


java.sql.Blob documentBlob = results.getBlob(1);

com.adobe.idp.Document document = new com.adobe.idp.Document(documentBlob.getBinaryStream());

patExecContext.setProcessDataValue("/process_data/@NewBigDocument", document);

java.sql.Clob stringClob = results.getClob(2);

patExecContext.setProcessDataValue("/process_data/@NewBigString", stringClob.getSubString(1L, (int)stringClob.length()));

} catch(Exception ex) {






Former Community Member

Just happen to refer to this thread.

You can use DBMS_LOB.SUBSTR to query repeatedly 4000 characters out of the field and concat them after finish.


DBMS_LOB.SUBSTR(FieldName, 2000, ?)
FROM TableName

? is replace with a counter, increase by 2000 each time.


Tuan Anh