2009-01-16

Debug Stored Procedure in TOAD

Pre condition: install/upgrade to version 9.6 or above of TOAD for Oracle.
Step 0: Debugger Options
View => Toad Options -> Debugger
Starting with the 10g release, Oracle offers a new interface, known as JDWP, for debugging PL/SQL and stored Java procedures. Toad fully supports both interfaces, but recommendation is to continue with DBMS_DEBUG unless you need to debug your Java code.
Step 1: Compile with Debug
1.1 Enable compile with debug: turn on the 'little green bug' button
1.2 Compile:
Database => Schema Browser -> My Schema -> Functions / Procedures / Packages
Right click on the procedure / package item, and then select "Compile" -> "Compile with Debug" from the popup menu.
Step 2: Load stored procedure code into the editor
Right click on the procedure / package item, and then select "Load in Editor" from the popup menu.
Step 3: Set breakpoints (Optional)
Click on the line number which you want the line to be a breakpoint
Step 4: Start debug:
4.1. Debug => Run / Run to Cursor / Step Over
Or click on the debug toolbar
Note: please choose "No" if you encounter following confirm window (when the code contains reference to other schema), otherwise you probably will run into privileges problem.
4.2. Set parameters:
Replace the NULLs with your test data value
Step 5: Use (Smart) Watches to view the PL/SQL variables value
When the execution pause at a breakpoint (current cursor), one can define watches or use the embedded Smart Watches (pay attention to "Enable Smart Watches" checkbox) to view variables value
For some detail explanations, please refer to http://docs.google.com/View?docid=dhq5wjmg_342dhsdnbdb

没有评论:

发表评论