DELETE PLAN_TABLE WHERE STATEMENT_ID = '&1.'
/
INSERT INTO PLAN_TABLE
(
ACCESS_PREDICATES,BYTES,CARDINALITY,COST,CPU_COST,DISTRIBUTION,FILTER_PREDICATES,ID,IO_COST
,OBJECT_NAME,OBJECT_NODE,OBJECT_OWNER,OPERATION,OPTIMIZER,OPTIONS,OTHER,OTHER_TAG,PARENT_ID,PARTITION_ID
,PARTITION_START,PARTITION_STOP,POSITION,SEARCH_COLUMNS,TEMP_SPACE,STATEMENT_ID,REMARKS,TIMESTAMP
)
SELECT
ACCESS_PREDICATES,BYTES,CARDINALITY,COST,CPU_COST,DISTRIBUTION,FILTER_PREDICATES,ID,IO_COST
,OBJECT_NAME,OBJECT_NODE,OBJECT_OWNER,OPERATION,OPTIMIZER,OPTIONS,OTHER,OTHER_TAG,PARENT_ID,PARTITION_ID
,PARTITION_START,PARTITION_STOP,POSITION,SEARCH_COLUMNS,TEMP_SPACE,HASH_VALUE,ADDRESS,SYSDATE
FROM V$SQL_PLAN
WHERE HASH_VALUE = '&1.' AND ADDRESS = '&2.' -- AND CHILD_NUMBER = 0 -- PEGANDO A PRIMEIRA CÓPIA? PROBLEMAS DE PERFORMANCE QUANDO HÁ MUITAS COPIAS
AND CHILD_NUMBER = (SELECT MAX(CHILD_NUMBER) FROM V$SQL_PLAN WHERE HASH_VALUE = '&1.' AND ADDRESS = '&2.' )
/