The DB2 SQL Debugger has been designed to help with testing and debugging of SQL stored procedures for DB2 versions 9.0 and above.
Launching the DB2 SQL Debugger
The DB2 Debugger is launched through a right-click in the Schema Browser on Stored Procedures and selecting Debug in Procedure Debugger from the popup menu. More than one debugger can be open at once, with each object to be debugged opened in a separate tab.
Debugger Workspace
The debugger displays a slightly modified version of the Query Analyzer Toolbar containing debugger-specific menus and buttons. Along the top of the debugger is the Execute, Stop, Step Into, Step Over, Step Return, Toggle Breakpoint, Turn On Profiling, Target Query Window, Debugger Query Window buttons. Next to the buttons is the Display Max Results input field. Beneath the buttons are the connection information, username, and SID information.
The procedure displays in the debugging window, within which breakpoints can be added by right-clicking and selecting "Toggle Breakpoint" from the popup menu. When this window has focused, and a line has been clicked, it is also possible to select "Run to Cursor," to run the debugger up to that line in the procedure. From the same popup menu, "Go to Current Line" brings the cursor to the current line, which is very useful when debugging multiple lengthy procedures.
Below the debugger window are tabs for Console, Breakpoints, Variables, Watches, Stack Frames, and Profile. The Console tab displays any errors or messages generated as debugging progress. The Breakpoints tab indicates the lines of the procedure where breakpoints are set and allows them to stop execution or not. The Variables tab lists any variables by name, their value, and type. The Watches tab allows selecting specific variables to be observed as they change, reducing from a possible list of hundreds to a select group. The Stack Frames tab lists the local variables of the functions and the arguments to them. The Profile tab lists commonly used terms or values a user works with on a regular basis in the debugging process.
Once execution of a procedure has begun through the use of the Start button at the top of the debugger window, the bottom left of the window is occupied by the Text, Text History, Grid, and Pivot Grid Results tabs. This area functions just as the Query Analyzer window does, revealing the results of procedures at each breakpoint or execution cursor.
The DB2 SQL Debugger features include: