Today I wanted to use dbms_sqltune on a SQL statement that was run on Friday, but had not been executed since then. dbms_sqltune by default will assume the statement is still in the shared pool. If it is not, you must use one of the overloaded procedures for create_tuning_task.
See below…
variable l varchar2(4000)
begin
:l := dbms_sqltune.create_tuning_task(begin_snap => 47631, end_snap => 47637,
sql_id=>'gjnx2b8t0nz90',task_name=>'wcrs');
end;
/