If you must trace EVERY statement in your stored procedure or trigger, then you do not want to spend time to write a WRITETRACE statement for every SQL statement. Instead, you can simply turn on “PROCTRACE”, which traces every statement inside the specified stored procedure or trigger. As with USERTRACE, you can turn proctrace on for a specified procedure, a specified trigger, or for all triggers associated with a particular table. The syntax is:
ADMIN COMMAND 'proctrace { on | off } userusername { procedure | trigger | table } entity_name'
The entity_name is the name of the procedure, trigger, or table for which you want to turn tracing on or off.
Trace is activated only when the specified user calls the procedure / trigger. This is useful, for example, when tracing propagated procedure calls in a advanced replication master.
Turning on tracing turns it on in all procedure/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 username, then all of the calls in all of those connections will be traced. Furthermore, the tracing will be done on calls propagated to (executed on) the master, as well as the calls executed on the replica.
If the keyword “table” is specified, then all triggers on that table are traced.