Working in Oracle APEX across multiple environments DEV, TEST, and PROD is risky business if you don’t have clear visual indicators. All it takes is one slip-up to run tests in production or drop data where you shouldn’t. In this guide, I’ll walk you through building an advanced, styled, and environment-aware banner in Oracle APEX.
The concept is simple: you display a dynamic banner at the top of every page that tells you exactly where you are. But the execution? That’s where we take it to the next level.
1. Why Use an Oracle APEX Environment Banner?
If your team works across multiple environments, this banner serves as a visual firewall. Here’s why it’s non-negotiable:
- Immediate Context: Know if you’re in DEV, TEST, or PROD at a glance.
- Prevent Costly Errors: Avoid running destructive processes in the wrong place.
- Show Live Data: Include real-time schema name, DB version, and APEX version.
This feature becomes especially important in high-pressure deployment or testing scenarios, where a small mistake can lead to huge setbacks.
2. Global Placement via Page 0
Oracle APEX Page 0 acts as a global layout. Anything you build here reflects across the entire app, except login pages. This is where we’ll place our environment banner to ensure maximum visibility without touching individual pages.
Steps:
- Navigate to Page 0 in your APEX app.
- Add a new Blank with Attributes region.
- Set Position to Banner or Top.
- Change Region Type to Dynamic Content.
- Select PL/SQL Function returning CLOB.
3. Build the Banner Using PL/SQL
Here’s a PL/SQL block that generates the full banner, including live environment metadata:
DECLARE
l_html CLOB;
l_apex_ver VARCHAR2(50);
l_db_ver VARCHAR2(50);
l_schema VARCHAR2(100);
l_db_time VARCHAR2(50);
BEGIN
SELECT version_no INTO l_apex_ver FROM apex_release;
l_db_ver := DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE;
l_schema := sys_context('USERENV','CURRENT_SCHEMA');
l_db_time := TO_CHAR(SYSDATE, 'DD.MM.YYYY HH24:MI:SS');
l_html := q'[
<div class="env-banner">
DEVELOPMENT ENVIRONMENT
]'
|| ' | APEX: ' || l_apex_ver
|| ' | DB: ' || l_db_ver
|| ' | Schema: ' || l_schema
|| ' | Time: ' || l_db_time
|| q'[
</div>
<style>
.env-banner {
background: linear-gradient(90deg, #ac630c, #d88432, #ac630c);
background-size: 300% 300%;
animation: smoothGradient 12s ease infinite;
color: #fff;
text-align: center;
font-size: 11px;
font-weight: 600;
padding: 3px 0;
letter-spacing: 2px;
text-transform: uppercase;
font-family: Arial, sans-serif;
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
@keyframes smoothGradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
</style>
]';
RETURN l_html;
END;
This will output a banner with schema name, APEX version, DB version, and current timestamp.
4. Apply the Banner to the Login Page
The login page (usually Page 9999) doesn’t inherit Page 0. But you still want the banner to appear there.
- Navigate to Page 9999.
- Add a Blank with Attributes region.
- Position it in Body Header.
- Use the same PL/SQL block as above.
Now users see the same banner even before logging in.
5. Show Banner Only in DEV or TEST Using Authorization Scheme
To prevent this banner from appearing in production, use an Authorization Scheme based on schema name.
- Go to Shared Components > Security > Authorization Schemes
- Create a new scheme with Name: ONLY_DEV_ENV and Type: PL/SQL Function Returning Boolean
DECLARE
v_schema VARCHAR2(100);
BEGIN
SELECT sys_context('USERENV','CURRENT_SCHEMA')
INTO v_schema
FROM dual;
IF lower(v_schema) LIKE '%dev%' THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
Apply this scheme to your Page 0 banner region. Now your banner is smart. It appears only in development environments, stays hidden in PROD, and reinforces safety.
6. Customizing for Test and Prod
You can take it even further:
- Use color coding: Green for DEV, Yellow for TEST, Red for PROD.
- Store environment settings in a configuration table (ENV_TYPE, APEX_BUILD_ID, etc.)
- Fetch that info dynamically in your PL/SQL and switch banners based on conditions.
This makes your banner adaptive and fully centralized.
7. Key Benefits Recap
- Safety First: Prevent mistakes in production.
- Instant Debugging Context: Know exactly where and what you’re running.
- Team Confidence: Makes staging and QA more transparent.
- Modern UI Touch: Gives a polished, branded feel.
8. Final Tips
- Don’t hardcode logic; use schema or environment tables.
- Keep your PL/SQL banner code in a shared package for reusability.
- Pair with build options or APEX global variables for cleaner control.
- Test visibility across multiple roles and logins.
You’ve now built a production-safe, visually distinct, environment-aware banner for Oracle APEX apps. You’ve covered visibility, environment awareness, and dynamic rendering.
Need a version with German/English switch? Want to include versioning info from Git or Jenkins? Let me know in the comments and I’ll extend it.
Stay sharp and keep your schemas separated.
Hassan Raza
Oracle ACE Apprentice, Pakistan