First, add the Attach External Session button to the Editor toolbar:
- R-click on the Editor toolbar
- Select "customize toolbars"
- In the commands tab, select the Debug category
- Drag/drop the "Attach External Session" button to the Editor toolbar or menu
- Close the Customize Window
Next, run this sample scenario...
This is the code I wish to debug. Compile this in Toad and have it open in Editor.
CREATE OR REPLACE PROCEDURE external_dbg_test
AS
n NUMBER;
BEGIN
n := 0;
n := 1;
END;
/
In SQL*Plus run the following, TOAD_EXAMPLE can be any string value...
SET SERVEROUTPUT OFF
ALTER SESSION SET PLSQL_DEBUG=TRUE;
DECLARE
id varchar2(255);
BEGIN
id := DBMS_DEBUG.INITIALIZE('TOAD_EXAMPLE');
DBMS_DEBUG.DEBUG_ON;
END;
/
In Toad click the Attach External Session button and enter the string used in the call to DBMS_DEBUG.INITIALIZE, TOAD_EXAMPLE in this demo. Toad will appear to be hung, this is expected.
In SQL*Plus run the following...
BEGIN
external_dbg_test;
DBMS_DEBUG.DEBUG_OFF;
END;
/
Toad will break on the first executable line. You can then set BPs, step through, evaluate watches, etc. just as you expect.