Debugging a Procedural Object

Proceed with debugging once breakpoints have been set for a procedural object in the Database Development perspective.

Execution of a procedural object in the Database Debug perspective differs from exeuction in Run mode in that execution can be suspended and resumed with breakpoints, and the procedural object variables and expressions can be observed and evaluated.

There can be one active connection to SQL Anywhere and Sybase IQ during a debug session. Disconnect other SQL Anywhere or Sybase IQ connection profiles before debugging.

You can use the Debug view toolbar during a debug session to resume, suspend, or terminate execution of a procedural object. There are several ways to suspend or terminate execution of a procedural object during debugging. Use the one appropriate to your situation.

Similar to a launch configuration, a Database Debug session remembers the SQL statement each time you want to test your object. In addition, it allows you to examine and manipulate variables and parameters and execute procedural objects one breakpoint at a time.

Use one of three methods to launch a session: from the Database Development perspective, from the Eclipse toolbar, or from the procedural object's editor.

You can set breakpoints by double-clicking the left vertical ruler in SQL File Editor or the procedural object editor's Source page, or by right-clicking the left vertical ruler and selecting Toggle Breakpoint. The Toggle breakpoint can also be used for setting the breakpoint. If the line is not appropriate for a breakpoint, the marker (a blue dot) automatically adjusts to the next appropriate line in the code. You can remove breakpoints by double-clicking or right-clicking the marker and selecting Toggle Breakpoint.

After you set the breakpoints, the Debug command switches the perspective to the Database Debug perspective and suspends execution at the first breakpoint. While switching the perspective, click OK on the dialog that appears to confirm the perspective switch.


Note: The Adaptive Server Enterprise SQL debugger can be disabled using traceflag 4083. The traceflag is a startup-only traceflag and has to be specified while starting up Adaptive Server Enterprise. Turning the traceflag on or off while Adaptive Server Enterprise is running will not have any effect on the state of the debugger.
  1. Once you have set breakpoints, select Debug from one of the following:
    • The main toolbar. This choice executes the procedural object as is.

    • From the Database Development perspective.
    • The editor.

    • The Run menu. You can use an existing launch session or set up a new session with the Create, Manage, and Run Configurations page.

    The Configure Parameters dialog appears. You can change parameters manually here.
  2. If prompted, click Yes to confirm a perspective switch to the Database Debug perspective.
  3. Use the following controls to navigate procedural object SQL code:
    Table 1. Methods of terminating or suspending procedural object execution
    Icon Action Description
    suspend execution between breakpoints Suspend Suspends execution between breakpoints or before the debug operation reaches the end of the procedure.
    terminate execution of procedural object Terminate Terminates execution of the procedural object.
    disconnect client debugger from remote debug client Disconnect Disconnects a client debugger from a remote debug target.
    clear terminated debug targets from SQL Editor Remove all terminated launches Clears all terminated debug targets.
    resume a suspended thread Resume Resumes a suspended thread.
    Arrow indicates highlighting the statement Step into The next statement on the currently-selected line to be executed is invoked, and execution suspends at the next executable line in the procedural object. If the statement is another stored procedure, as in a nested stored procedure, that procedural object loads into the editor window, and the first statement in that stored procedure is highlighted. The statement is highlighted at each step.
    Arrow indicates highlighting the statement Step over Skips the present highlighted statement and executes the next line in the same procedural object. If execution is at the end of a procedural object, execution continues in the procedural object from which the current procedural object was called. The cursor jumps to the declaration of the procedural object and highlights its line.
    Arrow indicates highlighting the statement Step return Returns the highlight to the previous stored procedure call level. Step Return is usually used in concert with Step Into.
  4. To debug procedural objects as you step through the code, examine or change the values of local variables.

    In the upper right corner of the Database Debug perspective, the Variables view tracks the variables used in the procedural objects. To change the value of a variable, right-click the variable in this view, and choose Change from the context menu. When the Set Value dialog appears, enter a new value for the variable and click OK.

    Note: The code is highlighted, where you can execute only that portion by choosing Execute Selection from the context menu.
  5. To navigate easily to a particular statement or variable, click on that statement in the Outline view, or expand Parameters and click on that variable.

    The statement or variable is highlighted in the editor window.

Next 

Examine and edit tables referenced in the object you are debugging.

Related tasks
Debugging a Table in Referenced Tables View
Debugging a Trigger
Debugging an External Client
Related reference
SQL Debugger

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.