TRACE ON
traces all statements except SQL statements. The contents of variables are printed before they are used. Routine calls and returned values are also traced.
TRACE PROCEDURE
traces only the routine calls and returned values.
TRACE expression
prints a literal or an expression. If necessary, the value of the expression is calculated before it is sent to the file.
The following example shows how you can use the TRACE statement in an SPL function.
Figure 14-106
With the TRACE ON statement, each time you execute the traced routine, entries are added to the file you specified in the SET DEBUG FILE statement. To see the debug entries, view the output file with any text editor. The following list contains some of the output generated by the function in Figure 14-106. Next to each traced statement is an explanation of its contents.
echoes TRACE ON statement.
TRACE Foreach starts
traces expression, in this case, the literal string Foreach starts.
start select cursor
provides notification that a cursor is opened to handle a FOREACH loop.
select cursor iteration
provides notification of the start of each iteration of the select cursor.
expression: (+lcount, 1)
evaluates the encountered expression, (lcount+1), to 2.
(lcount+1)
let lcount = 2
echoes each LET statement with the value.