TKPROF Shows alter statement last

hi,
I'm using the following version of Toad.
Toad for Oracle Xpert (64-bit) (Multiple Keys Active)
Add-Ons: DB Admin Module
17.0.353.2906

I was just wondering if someone could help me with some of the output of the TKPROF utility. After I run a query and enable SQL Trace (tkprof) and select the "Retrieve trace file after execution" checkbox, the query itself appears before the alter session set events command in the sequence of events. Doesn't the alter session set events '10046 trace name context forever, level 12' need to issued first?

Thanks for the help.

Yes. Toad runs an 'alter session' to start the trace, followed by your SQL, followed by another 'alter session' to stop the trace.

It's possible that TKProf is just putting things out of order. Or, maybe the 'alter session' that you're seeing is the one that turns tracing back off. Not sure.

thanks for the response. No, I'm seeing both the alter session to start and stop the trace appear after the SQL of interest.

We just start the trace, run your SQL, then stop the trace. What Oracle does with that in the trace file and TKProf is out of our control.