| |
 |
|
Oracle opaque_transform hint tips
Oracle Tips by Burleson Consulting
February 8, 2008
|
Oracle provides the undocumented opaque_transform hint to allow
distributed databases to communicate. It's not uncommon to see the
opaque_transform hint in a distributed query where Oracle has automatically
injected this hint in the remote SQL.
SELECT /*+ OPAQUE_TRANSFORM */ col1, col2 . . . .
I'm told that with an opaque_transform hint added to a subquery,
Oracle will
transform parts of the SQL into an earlier dialect. When used in remote
distributed queries between versions. However, we also see queries that do
not do transformation with this hint:
SELECT /*+ OPAQUE_TRANSFORM */ count(*)
FROM "AF_FUND_HIERARCHY" "AF_FUND_HIERARCHY_SOURCE_DB"
Transform for syntax conversion?
Others say that opaque_transform is automatically injected into standard
remote SQL to convert later SQL constructs into older constructs. For
example, this remote query with a CASE statement might need to have the SQL CASE
transformed into a DECODE to communicate with an earlier release of Oracle:
Insert into
tmp_tst(decode_col,case_col)
SELECT decode(t1.t1_status,'A','S','O','N') dedode_col,
CASE WHEN
t1.t1_status = 'A'
THEN 'S'
WHEN t1.t1_status = 'O'
THEN 'N' END Case_col
FROM t1;
Rows Execution Plan
------- ---------------------------------------------------
0 INSERT STATEMENT MODE: ALL_ROWS
2 REMOTE OF 'T1' (REMOTE) [ORIGIN9I] SELECT
/*+ OPAQUE_TRANSFORM */ "T1_STATUS" FROM "T1"
"T1"
Transform for VARRAY to LOB?
Another theory suggests
that the
opaque_transform is related to the ORA-22997 error, and opaque_transform
may be converting opaque data types (abstract data types, (ADT)) into LOB
columns for insertion into earlier releases of Oracle:
ORA-22997 - VARRAY | OPAQUE stored as LOB is not specified at the
table level
Cause: An attempt was made to specify a VARRAY|OPAQUE column to be
stored as LOB at the partition/subpartition/template level. However the
VARRAY|OPAQUE column was not specified to be stored as LOB at the table
level when the table was created.
Action: Specify the VARRAY | OPAQUE column to be stored as LOB at
the table level when the table is created. Alternatively, do not specify the
VARRAY | OPAQUE column to be stored as LOB at the
partition/subpartition/template level if it is not specified at the table
level when the table is created.
Here is an example of the opaque_transform hint from some Oracle Applications
SQL:
SELECT /*+ OPAQUE_TRANSFORM */ "INVENTORY_ITEM_ID","ORGANIZATION_ID", "PRIMARY_UOM_QUANTITY","RESERVATION_TYPE","RESERVATION_QUANTITY",
"DEMAND_SOURCE_TYPE","DEMAND_SOURCE_HEADER_ID","COMPLETED_QUANTITY", "SUBINVENTORY","DEMAND_CLASS","REQUIREMENT_DATE","DEMAND_SOURCE_LINE",
"DEMAND_SOURCE_DELIVERY","DEMAND_SOURCE_NAME","PARENT_DEMAND_ID", "DEMAND_ID","SALES_ORDER_NUMBER","SALESREP_CONTACT","SALESREP_ID",
"FORECAST_VISIBLE","DEMAND_VISIBLE","RN1","RN2","RN3","PROJECT_ID", "TASK_ID","PLANNING_GROUP","CUSTOMER_ID","BILL_TO_SITE_ID",
"SHIP_TO_SITE_ID","REQUEST_DATE","LIST_PRICE","FIRM_DEMAND_FLAG", "SHIP_SET_ID","ARRIVAL_SET_ID","SHIP_SET_NAME","ARRIVAL_SET_NAME",
"END_ITEM_UNIT_NUMBER","ORDERED_ITEM_ID","CTO_FLAG","DEMAND_PRIORITY", "PROMISE_DATE","LINK_TO_LINE_ID","ORIGINAL_INVENTORY_ITEM_ID",
"ORIGINAL_SYSTEM_REFERENCE","ORIGINAL_SYSTEM_LINE_REFERENCE", "MFG_LEAD_TIME","AVAILABLE_TO_MRP","ORIGINAL_ORDERED_QUANTITY",
"ORIGINAL_COMPLETED_QUANTITY","CUST_PO_NUMBER","CUSTOMER_LINE_NUMBER", "ORDER_DATE_TYPE_CODE","SCHEDULE_ARRIVAL_DATE","LATEST_ACCEPTABLE_DATE",
"SHIPPING_METHOD_CODE","ATO_LINE_ID","DELIVERY_LEAD_TIME" FROM
"MRP_AN1_SALES_ORDERS_V" "X" WHERE ("ORGANIZATION_ID"=82 OR "ORGANIZATION_ID"=83
OR "ORGANIZATION_ID"=101 OR "ORGANIZATION_ID"=121 OR "ORGANIZATION_ID"=142 OR "ORGANIZATION_ID"=162
OR "ORGANIZATION_ID"=182 OR "ORGANIZATION_ID"=282 OR "ORGANIZATION_ID"=283 OR "ORGANIZATION_ID"=284
OR "ORGANIZATION_ID"=285 OR "ORGANIZATION_ID"=287 OR "ORGANIZATION_ID"=288 OR "ORGANIZATION_ID"=289
OR "ORGANIZATION_ID"=290 OR "ORGANIZATION_ID"=291 OR "ORGANIZATION_ID"=293 OR "ORGANIZATION_ID"=294
OR "ORGANIZATION_ID"=295 OR "ORGANIZATION_ID"=296 OR "ORGANIZATION_ID"=297 OR "ORGANIZATION_ID"=298
OR "ORGANIZATION_ID"=300 OR "ORGANIZATION_ID"=301 OR "ORGANIZATION_ID"=302 OR "ORGANIZATION_ID"=303
OR "ORGANIZATION_ID"=304 OR "ORGANIZATION_ID"=305 OR "ORGANIZATION_ID"=306 OR "ORGANIZATION_ID"=307
OR "ORGANIZATION_ID"=309 OR "ORGANIZATION_ID"=310 OR "ORGANIZATION_ID"=311 OR "ORGANIZATION_ID"=313
OR "ORGANIZATION_ID"=314 OR "ORGANIZATION_ID"=315 OR "ORGANIZATION_ID"=316 OR "ORGANIZATION_ID"=317
OR "ORGANIZATION_ID"=318 OR "ORGANIZATION_ID"=322 OR "ORGANIZATION_ID"=342 OR "ORGANIZATION_ID"=422)
AND "ORIGINAL_ORDERED_QUANTITY">="ORIGINAL_COMPLETED_QUANTITY" AND ("RN1">:1 OR
"RN2">:2 OR "RN3">:3)
 |
If you like Oracle tuning, you
might enjoy my book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get instant
access to the code depot of Oracle tuning scripts. |
|

|
|