Query works with Oracle 10g but not with 11g?

Peter Lang picture Peter Lang · Dec 6, 2010 · Viewed 8.4k times · Source
DECLARE
  trn  VARCHAR2(2) := 'DD';
  cur  SYS_REFCURSOR;
BEGIN
  OPEN cur FOR
    SELECT
      TRUNC(some_date, trn),
      NULL AS dummy_2,
      COUNT( DISTINCT dummy_1 )
    FROM
      (SELECT SYSDATE AS some_date, ROWNUM AS dummy_1 FROM dual)
    GROUP BY
      TRUNC(some_date, trn);
END;

This works with Oracle 10, but with Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production it results in:

ORA-00979: not a GROUP BY expression
ORA-06512: at line 5


Can anyone reproduce/explain this? Thanks!

Answer

Vincent Malgrat picture Vincent Malgrat · Dec 6, 2010

if you have access to support, it looks like Bug 9478304: LOOP FAILING WITH ORA-00979: NOT A GROUP BY EXPRESSION. This seems to affect 11.2.0.1 only.