Oracle: How to AUTOTRACE in my program You can display the results of EXPLAIN PLAN with

explain plan for select * from foo;
select * from table(dbms_xplan.display);


How can I similarly display the results for an AUTOTRACE in my program?
You'll have to write your own, it's not a native feature of oracle, it's something that has been implemented in Oracle tools. Grab the plan from v$sql_plan for your SQL_ID and then grab the delta of session stats before and after you run your query.

It's a little more involved in that, but that's the basic mechanics.