Getting Started

A PL/SQL procedure which has been instrumented with BMC_DEBUG has this basic structure :-

PROCEDURE procedure_name IS

BEGIN

bmc_debug.begincall('PACKAGE_NAME','PROCEDURE_NAME');

--

-- Your code goes here

--

bmc_debug.endcall('PACKAGE_NAME','PROCEDURE_NAME');

EXCEPTION

WHEN OTHERS THEN

bmc_error.error_handle();

RAISE;

END procedure_name;

The first statement in the procedure body must be the call to BMC_DEBUG.BEGINCALL, the first two parameters to which should be the names of the package and the procedure which is executing.

The last statement in the procedure should be the call the BMC_DEBUG.ENDCALL, which can also take the package and procedure names as parameters.

All instrumented procedures should have an outermost exception handler for WHEN OTHERS which calls the BMC_ERROR.ERROR_HANDLE procedure, and then reraises the exception with a RAISE statement. If an instrumented procedure encounters an unhandled exception which hits the WHEN OTHERS handler, ERROR_HANDLE writes the exception details to the BMC_DEBUG_LOG table (along with other useful information), and removes the top entry from the call stack to keep it consistent.

If you want to instrument an existing codebase, the main task is to add the calls to BEGINCALL and ENDCALL, and the exception handler, to the existing procedures and functions. It is also possible to instrument triggers, so that details of when triggers fire and what they do are written to the debug log (see Instrumenting Triggers for more details).

Many of the following chapters contain runnable code examples which you can copy and paste into SQL*Plus. You can run the examples in the same schema into which you've installed BMC_DEBUG.