Published: 2/19/2026 Code Instrumentation APEX PL/SQL Code Instrumentation Example DECLARE l_scope VARCHAR2(4000) := $$plsql_unit_owner; l_debug_template VARCHAR2(4000) := l_scope || ' %0 %1 %2 %3 %4 %5 %6 %7'; l_parameter VARCHAR2(4000) := 'value1'; l_id NUMBER ; BEGIN apex_debug.message(l_debug_template, 'START: ', 'p_parameter', l_parameter); apex_debug.info(l_debug_template, 'PARAMETERS: ', NULL, 'l_parameter', l_parameter); -- BUSINESS LOGIC STARTS -- force a division-by-zero error l_id := 1 / 0 ; -- BUSINESS LOGIC ENDS apex_debug.message(l_debug_template, 'STOP'); EXCEPTION WHEN OTHERS THEN -- Catch any other exceptions and log them as critical errors apex_debug.error( p_message => l_debug_template, p0 => 'STOP: Unhandled Exception', p1 => 'error_stack', p2 => dbms_utility.format_error_backtrace, p3 => sqlcode, p4 => sqlerrm, p_max_length => 4000 ); -- Optionally, re-raise the exception or handle it further -- Additionally, you might raise a user-friendly message raise_application_error(-20001, 'An internal error occurred. Please contact support.'); END; ReportingSELECT message_level, application_id, page_id, message_timestamp, message, apex_user, call_stack FROM apex_debug_messages WHERE application_id = nvl(:app_id, application_id) AND message_level < 5 AND page_id = :page_id ORDER BY message_timestamp DESC;