Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle 9i query results differ from Oracle 8i! Is Oracle 9i reliable when using complex queries with analytic functions? This is very serious question!
Hi, all!
FOREWORD
PROBLEM
SELECT
dept.dname,
rlp_join.rlp_name,
rlp_join.s_sal
FROM (SELECT
dept.dname, rlp.dname rlp_name, rlp.s_sal FROM ( SELECT jn.dname, SUM (emp.sal) s_sal FROM ( SELECT dept.dname, emp.ename, emp.sal sal FROM emp, dept WHERE emp.deptno = dept.deptno) jn, emp WHERE jn.ename = emp.ename GROUP BY ROLLUP (jn.dname) ) rlp, dept WHERE dept.dname = rlp.dname) rlp_join, dept
Oracle 9.2.0.5 EE dives 4 rows.
Oracle 8.1.7.4 EE dives just one row which is RIGHT!
Listing of the tests is included at the bottom of this message.
HOW TO REPROCUDE THE PROBLEM
Here are some additional facts:
1. When the keyword "ROLLUP"; is excluded from the query;
results are the same (1 row);
2. When RLP_JOIN inline view is replaced with an equivalent table
(CTAS for it); results are the same.
I've heard of a problem with merging views in former versions of 9i. AFAIK it could lead to an error. But it was fixed in 9.2.0.4, BICBW. I have also tried the following:
1. Set _COMPLEX_VIEW_MERGING to FALSE; 2. Use NO_MERGE hint the query. 3. Setting COMPATIBLE.
None of them were helpful. In the 3d case database startup failed
with
ORA-00402: database changes by release 9.2.0.0.0 cannot be used by
release 8.1.7.0.0;
ORA-00405: compatibility type "Locally Managed SYSTEM tablespace"
I'LL BE EXTREMELY GRATEFUL
Best regards,
Sergey Adamenko.
Senior Oracle DBA.
Kyiv, Ukraine.
E-mail: wadamenko_wusenet_at_wukr.net (remove 'w' from E-mail)
SQL> SQL> SQL> SELECT
6 dept.dname, 7 rlp.dname rlp_name, 8 rlp.s_sal 9 FROM (SELECT 10 jn.dname, 11 SUM (emp.sal) s_sal 12 FROM (SELECT 13 dept.dname, 14 emp.ename, 15 emp.sal sal 16 FROM emp, 17 dept 18 WHERE emp.deptno = dept.deptno) jn, 19 emp 20 WHERE jn.ename = emp.ename 21 GROUP BY ROLLUP (jn.dname)) rlp, 22 dept 23 WHERE dept.dname = rlp.dname) rlp_join,24 dept
DNAME RLP_NAME S_SAL
-------------- -------------- ----------
ACCOUNTING
OPERATIONS
RESEARCH
SALES
SQL> EXIT
[Oracle 8i]
I SQL>
SQL> SELECT * FROM V$VERSION;
BANNER
SQL> SQL> SQL> SELECT
6 dept.dname, 7 rlp.dname rlp_name, 8 rlp.s_sal 9 FROM (SELECT 10 jn.dname, 11 SUM (emp.sal) s_sal 12 FROM (SELECT 13 dept.dname, 14 emp.ename, 15 emp.sal sal 16 FROM emp, 17 dept 18 WHERE emp.deptno = dept.deptno) jn, 19 emp 20 WHERE jn.ename = emp.ename 21 GROUP BY ROLLUP (jn.dname)) rlp, 22 dept 23 WHERE dept.dname = rlp.dname) rlp_join,24 dept
DNAME RLP_NAME S_SAL -------------- -------------- ---------- OPERATIONS SQL> exit Received on Fri Mar 04 2005 - 06:49:00 CST