0

条件

  • SP 必须存在
  • 它在 10g 上有效,但在 11g 上无效
  • 我们可以运行一个程序来证明他们是否给出以下错误:

    • 循环失败并出现 ORA-00979: NOT A GROUP BY EXPRESSION (on 11 g)

11g有问题,10g没问题

CREATE TABLE testing (AAA NUMBER, BBB NUMBER);

DECLARE
CURSOR curTesting(myGroupID IN NUMBER) IS
SELECT DECODE(myGroupID, AAA, 'PP', 'PP_GROUP') AS p_type,
      COUNT(DISTINCT BBB) AS num_of
FROM testing
GROUP BY DECODE(myGroupID, AAA, 'PP', 'PP_GROUP')
ORDER BY p_type DESC;

BEGIN
FOR row IN curTesting(0) LOOP
NULL;
END LOOP;
END;

insert into testing values(1,2);
insert into testing values(1,2);

DECLARE
CURSOR curTesting(myGroupID IN NUMBER) IS
SELECT DECODE(myGroupID, AAA, 'PP', 'PP_GROUP') AS p_type,
      COUNT(DISTINCT BBB) AS num_of
FROM testing
GROUP BY DECODE(myGroupID, AAA, 'PP', 'PP_GROUP')
ORDER BY p_type DESC;

BEGIN
FOR row IN curTesting(0) LOOP
NULL;
END LOOP;
END;

ERROR at line 1:
ORA-979: not a GROUP BY expression
ORA-6512: at line 3
ORA-6512: at line 10
  • ORA-918 列定义不明确

11g有问题,10g没问题

select ps_id, product_scores.ps_id ps_id1, productId 
  from product_scores join (select ps_id productId from products_shop ) on
       productId = ps_ps_id     
 where rownum < 10;

解决方案:

select t1.ps_id, t1.ps_id ps_id1, productId
  from product_scores t1
       join (select ps_id productId from products_shop) 
         on productId = ps_ps_id
 where rownum < 10;

请编写查询以查看由于从 10g 升级到 11g 导致的无效 sp

4

0 回答 0