Using DBMS_ADVANCED_REWRITE When Binds Are Present (Avoiding ORA-30353)
(Doc ID 392214.1)
Last updated on FEBRUARY 15, 2019
Applies to:Oracle Database - Enterprise Edition - Version 10.1.0.2 to 18.104.22.168 [Release 10.1 to 11.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
When trying to use DBMS_ADVANCED_REWRITE to rewrite a query with bind variables in the where clause, the error ORA-30353 is signal.
This is a known and intended limitation in the functionality.
A rewrite of the query in spite of this limitation can still be accomplished, as shown in this article.
Here is a small testcase to demonstrate the above. It is assumed that the prerequisites for rewrite equivalence are satisfied in the current session i.e. user has execute privilege on DBMS_ADVANCED_REWRITE, query_rewrite_enabled=true and query_rewrite_integrity=trusted (or stale_tolerated)
NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.
The message for ORA-30353 is:
30353, 00000, "expression not supported for query rewrite"
// *Cause: The select clause referenced UID, USER, ROWNUM, SYSDATE,
// CURRENT_TIMESTAMP, MAXVALUE, a sequence number, a bind variable,
// correlation variable, a set result,a trigger return variable, a
// parallel table queue column, collection iterator, etc.
// *Action: Remove the offending expression or disable the REWRITE option on
// the materialized view.
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!
In this Document