TRUNCATE TABLE rewrite_table;

DECLARE
  querytxt VARCHAR2(1500) := 'select c.cust_last_name, c.cust_credit_limit,'
    ||
    ' SUM(amount_sold) AS dollar_sales ' ||
    'FROM sales s, customers c ' ||
    'WHERE s.cust_id= c.cust_id ' ||
    'GROUP BY c.cust_last_name, c.cust_credit_limit';
BEGIN
  dbms_mview.Explain_Rewrite(querytxt, NULL, 'ID1');
END;
/


SELECT message
FROM   rewrite_table
ORDER BY sequence DESC;
