What Are Application Processes
Application processes are PL/SQL blocks that run at specific points during every page request. Unlike page processes tied to a single page, application processes execute globally. They are configured in Shared Components and are essential for session-wide state, global business rules, and code that runs on every request.
Process Points
On New Session: Runs once when a session is created. Ideal for loading user preferences:
BEGIN
SELECT default_language, theme_preference, items_per_page
INTO :G_LANGUAGE, :G_THEME, :G_PAGE_SIZE
FROM user_preferences WHERE username = :APP_USER;
EXCEPTION
WHEN NO_DATA_FOUND THEN
:G_LANGUAGE := 'EN'; :G_THEME := 'LIGHT'; :G_PAGE_SIZE := 25;
END;
Before Header: Runs before every page render. Use for notification counts or alert checks.
On Demand (AJAX Callback): Creates a named PL/SQL entry point callable from JavaScript:
-- Application Process: GET_EMPLOYEE_COUNT
DECLARE l_count NUMBER;
BEGIN
SELECT COUNT(*) INTO l_count FROM employees
WHERE department_id = APEX_APPLICATION.G_X01;
HTP.P(l_count);
END;
// JavaScript:
apex.server.process("GET_EMPLOYEE_COUNT", {x01: deptId}, {
success: function(data) { apex.item("P10_COUNT").setValue(data); }
});
Conditions and Sequence
Each process can have a Server-Side Condition controlling execution. The Sequence number controls order. Keep sequences well-spaced (10, 20, 30) to allow inserting new processes later.
Performance Considerations
Before Header processes run on every page view. Keep them lightweight. If a process involves expensive queries, cache the result in an application item refreshed only when data changes rather than recalculating on every load.