ORA-01791: not a SELECTed expression after upgrade to 11.2.0.4 (文档 ID 1600974.1)
来源:互联网 发布:加好友软件qq2016 编辑:程序博客网 时间:2024/05/18 00:56
In this Document
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.2.0.4 and laterInformation in this document applies to any platform.
SYMPTOMS
a select DISTINCT query and the order by column does not reference a select list item after upgrade to 11.2.0.4
select distinct sal, empno from scott.emp order by deptno
*
ERROR at line 1:
ORA-01791: not a SELECTed expression
But it was working on previous release ..
SAL EMPNO
---------- ----------
2450 7782
5000 7839
CHANGES
upgrade to 11.2.0.4
CAUSE
The issue have been investigated in the following bug:
Bug:17655864 - ORA-01791: NOT A SELECTED EXPRESSION AFTER 11.2.0.4 PATCH
which is closed as not a bug. and this is expected behvior .
so the correct behavior is on 11.2.0.4 and not older versions.
This is due to
BUG 13768663 - SELECT WORKS IN 10.2 AND 11.2.0.3 FAILS 11.1.0.7 ORA-01791
Invalid query which should raise ORA-1791 is working fine without any error starting from 11.2.0.1.This is fixed in 11.2.0.4 and hence you may get the error ORA-1791 in 11.2.0.4.
SOLUTION
The expected behaviour for this statement is that it should report ORA-01791 That is, this is a select DISTINCT query and the order by column does not reference a select list item. This is a documented restriction of the order by clause.
This behaviour is corrected through bugfix 13768663.
so please add the orderby column in the select statement
SQL> select distinct sal, empno, deptno from scott.emp order by deptno;
SAL EMPNO DEPTNO
---------- ---------- ----------
2450 7782 10
5000 7839 10
1300 7934 10
REFERENCES
BUG:17655864 - ORA-01791: NOT A SELECTED EXPRESSION AFTER 11.2.0.4 PATCHNOTE:13768663.8 - Bug 13768663 - ORA-1791 not reported in 11.2 when expected
BUG:13768663 - SELECT WORKS IN 10.2 AND 11.2.0.3 FAILS 11.1.0.7 ORA-01791