
prompt select /*+ gather_plan_statistics */  /* '%LOOK_AT_ME%' */  * from dual;
prompt the funny LOOK_AT_ME is only used to identify your relevant sql statemens
prompt you can use any string to get the relevant sql_id afterwards (try timesrtamps)
 

set echo off
set verify off
set termout off
column sql_id new_val sql_id
column sql_hash new_val sql_hash
column child_number new_val child_number
set lin 32000

SELECT
MAX(SQL_ID) KEEP  (dense_rank last order by last_load_time) sql_id         , max(child_number) keep  (dense_rank last order by last_load_time ) child_number         , max(hash_value) keep   (dense_rank last order by last_load_time  )       sql_hash
--a.*
from v$sql  a
where upper(sql_text) like '%LOOK_AT_ME%' and   sql_text not like '%v$sql%'  ;
/


set termout on
set feedback off
select * from table(dbms_xplan.display_cursor('&sql_id',&child_number,'ALLSTATS LAST ADVANCED MEMSTATS PARTITION'))
/
set feedback on
set echo off
set verify on
prompt   exec dbms_outln.create_outline(&sql_hash, 0, 'TEST')
set feedback on
set echo on
set verify on


