Stored Procedure Debugging

Stored Procedures are a powerful mechanism for data processing without having to transfer data from the database to a client running the code. Instead, the code is executed on the database server, directly in the database system.

Stored code routines like procedures, functions, triggers and packages (collections of routines) are supported by many database systems. It's also a method of centralizing code, that can be used with different clients like desktop applications or a mobile app.

This also means you cannot easily debug the code, as your application development environment is different from the database. This is where the Stored Code Debugger comes into play.

  • Execute stored code line by line
  • Set (conditional) breakpoints to halt execution
  • Modify parameter and variable values during execution
  • Query data to check if the query is executed correctly

How does the debugger work?

When starting the debugger from the context menu in the Database Navigator, you can enter parameter values. After that, the routine is started at the first line of code.

Database Workbench uses client side code emulation for Firebird, InterBase and MySQL as these database systems do not provide server side debugging. It supports native server side debugging for Oracle and PostgreSQL.

After starting, you can step through lines one by one, you can trace into routines that are called from within the code. Doing so will open another tab with the stored source code and continue executing on the new tab.

Detailed view

The debugger shows you all relevant details.

  • Parameter and variable values
  • Result for functions or other data sent to the caller
  • Routine call stack
  • Breakpoints, including conditions
  • Execution messages

Check your triggers

For trigger debugging, you can easily select the data for which you want to trigger this specific piece of code.

You can set the trigger timing and operation. If the trigger has a BEFORE and AFTER context, you can select two sets of data to start the trigger.