Rendering HTML Using Custom PL/SQL

 Requirement

You have some HTML stored in a database, and you want to display it in Apex.

What didn't work

I tried creating a hidden item to get my CLOB HTML data from my custom table. I then created a statuc region and then setting the source of the region where I wanted the HTML to display to be &P_ITEM.

This did not render the HTML, even though I set the escape characters to No for the region.

I tried using the new HTML attributes (&P1_TEXT!HTML.) as suggested here:

https://stackoverflow.com/questions/42151849/oracle-apex-5-1-passing-html-string-into-region

Solution

I created a region with with source of PL/SQL Dynamic Content.

Code for the source:

DECLARE

   v_content clob;

BEGIN

   SELECT help_text 

    INTO v_content 

    FROM table

    where id = v('REQUEST');

   htp.p(v_content);

END;


I now have HTML formatting with bold, titles, italics, tables etc, as below.




Acknowledgment

https://docs.oracle.com/database/apex-18.1/HTMDB/rendering-html-using-custom-plsql.htm#HTMDB06013


Comments