solidDB Help : Programming : Diagnostics and troubleshooting SQL : Tracing facilities for stored procedures and triggers
  
Tracing facilities for stored procedures and triggers
When debugging a stored procedure or a trigger, you might want to add "trace" commands to see which parts of the code are executing or you might want to trace every statement within the procedure or trigger.
User-definable trace output from procedure code
From inside your stored procedure or trigger, you can send trace output to the soltrace.out file by using the WRITETRACE statement, see CREATE PROCEDURE.
You can turn the output on or off by using ADMIN COMMAND 'usertrace', see USERTRACE.
Trace is activated only when the specified user calls the procedure or trigger. This is useful, for example, when tracing propagated procedure calls in an Advanced Replication master database.
Turning on tracing turns it on in all procedure and trigger calls by this user, not just calls from the connection that switched the trace on. If you have multiple connections that use the same user name, then all of the calls in all of those connections are traced. Furthermore, the tracing is done on calls propagated to (executed on) the master database, as well as the calls executed on the replica database.
Procedure execution trace
If you need to trace every statement in your stored procedure or trigger, then you can use ADMIN COMMAND 'proctrace', which traces every statement inside the specified stored procedure or trigger, see PROCTRACE.
Trace is activated only when the specified user calls the procedure or trigger. This is useful, for example, when tracing propagated procedure calls in an Advanced Replication master.
Example
"CREATE PROCEDURE trace_sample(i INTEGER)
RETURNS(j INTEGER)
BEGIN
      j := 2*i;
      RETURN ROW;
END";
COMMIT WORK;
ADMIN COMMAND 'proctrace ON USER dba PROCEDURE trace_sample';
CALL trace_sample(2);
Output from example:
23.01 17:25:17 ---- PROCEDURE 'DBA.DBA.TRACE_SAMPLE' TRACE BEGIN 0001:CREATE PROCEDURE TRACE_SAMPLE(I INTEGER)
0002:RETURNS(J INTEGER)
0003:BEGIN
      --> I:=2
      --> J:=NULL
      --> SQLSUCCESS:=1
      --> SQLERRNUM:=NULL
      --> SQLERRSTR:=NULL
      --> SQLROWCOUNT:=NULL
0004: J := 2*I;
      --> J:=4
0005: RETURN ROW;
0006:END
23.01 17:25:17 --- PROCEDURE 'DBA.DBA.TRACE_SAMPLE' TRACE END ---
Go up to
Diagnostics and troubleshooting SQL