Print CLOB Content in Oracle Apex

How to show clob content in oracle apex page ? is it possible to show ?

Yes, Possible to print clob content in oracle apex page with using of PL/SQL Dynamic Content Region.

Step 1: Split CLOB content into small pieces of content with using of dbms_lob.read procedure.

Example Code Snippet:

DECLARE
CURSOR crec IS
SELECT
html_message
FROM
mails_t
WHERE
email_id = 1001;
rrec crec%rowtype;

l_amt INTEGER := 4000;
l_pos INTEGER := 1;
l_buf VARCHAR2(32000);
BEGIN

OPEN crec;
FETCH crec INTO rrec;
CLOSE crec;

LOOP
BEGIN
dbms_lob.read(rrec.html_message, l_amt, l_pos, l_buf); /* Splitting the CLOB Content with buffer size */
l_pos := l_pos + l_amt;
l_amt := 4000;
htp.p(l_buf); /* Print Content */
EXCEPTION
WHEN no_data_found THEN
EXIT;
END;
END LOOP;
END;

Step 2: Create PL/SQL Dynamic content region and enter above Pl/SQL code. It can split the clob content into bits and pieces of content and then print the content in Apex Page.

Happy Apexing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s