In this Document
APPLIES TO:Oracle Database - Enterprise Edition - Version 11.2.0.4 and laterInformation in this document applies to any platform. SYMPTOMSa select DISTINCT query and the order by column does not reference a select list item after upgrade to 11.2.0.4
SQL> select distinct sal, empno from scott.emp order by deptno;
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 ..
SQL> select distinct sal, empno from scott.emp order by deptno;
SAL EMPNO ---------- ---------- 2450 7782 5000 7839
CHANGESupgrade to 11.2.0.4 CAUSEThe 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. SOLUTIONThe 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. SQL> select distinct sal, empno, deptno from scott.emp order by deptno; REFERENCESBUG: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 | ![]() |
![]() |
