Rendering HTML with/without PL/SQL in Oracle APEX (New Versions 24.X)

 


In older versions of Oracle APEX, developers often used the Region Type: PL/SQL Dynamic Content and wrote code with htp.p to directly print HTML to the page.
However, in newer versions  APEX 23.2, 24.x , this region type has been deprecated. Oracle now recommends cleaner and safer methods to generate and display HTML, typically using templates and modern region types.


👉Render HTML in Oracle APEX:

1Dynamic Content (Recommended)
2. Using htp.p in PL/SQL Processes (Legacy), we should discuss it 😳
3. Static Content Region
4. Reports with HTML Expressions



 Let's Go :

1Dynamic Content (Recommended)

Dynamic Content with PL/SQL Function Returning HTML 

This is the official replacement for the old Dynamic PL/SQL Content. After this section in section 2 (Using htp.p in PL/SQL Processes), I will discuss it.


Example:

declare l_html clob; begin l_html := '<h2 style="color:blue;">Hello Oracle APEX !</h2>' || '<p>This is a sample text generated with PL/SQL.</p>'; return l_html; end;

* This works exactly like htp.p, but it returns the content instead of printing it.


2.Using htp.p in PL/SQL Processes (Legacy)

Region Type: PL/SQL Dynamic Content

Although not recommended, you can still use htp.p inside PL/SQL Processes or certain rendering points.


Example:

begin htp.p('<div style="color:red;">Hello! This text is printed with htp.p</div>'); end;

This approach is not supported for modern region rendering and should only be used in special cases.


3. Static Content Region

If your HTML is fixed and not generated dynamically, the easiest solution is:

  • Create a Static Content Region.

  • Place your HTML directly into the Source.



Example:

<h1 style="color:green;">Welcome!</h1> <p>This is static HTML content.</p>


4. Reports with HTML Expressions

For dynamic data (like user lists, orders, etc.):

  • Create a Classic Report or an Interactive Report.

  • In the Column settings, use HTML Expression to render HTML in your results.

Example:

select username, '<span style="color:blue;">' || email || '</span>' as email_html from users;


TIPS:

Use  apex_escape.html when displaying user input to avoid XSS attacks.For Example:

l_html := '<p>' || apex_escape.html(:P1_USER_INPUT) || '</p>';

Comments

Popular posts from this blog

JavaScript In Oracle APEX (Client Side)

Installation of Oracle Database 23ai and APEX 24.2 and ORDS 24.4 on Windows Step-by-Step

Building a Fully Local AI-Powered Assistant with Oracle APEX and Vector Search #APEXCONN2025 #orclAPEX

Configuration of ORDS: Standalone, Tomcat, and WebLogic on Windows Step-by-Step

✔ RTL Map Region Labels APEX 24.2 & 🌍GeoCoding

Oracle JET and Oracle APEX are best friends💕

Vector Tiles in Oracle Spatial 23

Building an AI-Powered Resume Matching System Using Oracle APEX and 23ai Vector Search😎

What is SYS.ODCI (SYS.ODCINumberList or SYS.ODCIVarchar2List) and How Can Use it in APEX ?

My Experience at Oracle CloudWorld Tour in Frankfurt – April 10, 2025