可能的Oracle Bug"大于0"在哪里条款

时间:2014-08-22 09:01:06

标签: sql oracle select

我有一个select语句,它提供了错误的行数。 我可以在Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionOracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production上重现问题我无法在Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production上重现

TESTDATA:

CREATE TABLE PERSON AS
SELECT LEVEL AS ID, 'Person_'||LEVEL AS NAME, 10 as maxVal
FROM DUAL 
CONNECT BY LEVEL <= 5;

create table orders as
SELECT LEVEL AS ID, 'Order_'||LEVEL AS NAME
FROM DUAL 
CONNECT BY LEVEL <= 3;

如果我尝试以下查询,我只得到3个结果而不是5个结果:

select p.*
      from person p
     where (maxVal - (select count(*)
                         from orders o
                        where o.id = p.id)
           )  > 0

如果我将查询修改为以下内容,我会得到5个结果(应该是正确的数字):

select p.*
      from person p
     where (maxVal - (select count(*)
                         from orders o
                        where o.id = p.id)
           )  > 1

以下修改也会提供正确的结果:

select p.*
      from person p
     where (maxVal - (select count(*)
                         from orders o
                        where o.id = p.id)
           )  > 0 + 0

如果我使用Bind Variables,我也会得到正确数量的结果:

select p.*
      from person p
     where (maxVal - (select count(*)
                         from orders o
                        where o.id = p.id)
           )  > :num

那么,如果我使用“大于0”,是否有(已知)Bug?

1 个答案:

答案 0 :(得分:1)

这是另一个错误修补后出现的错误。

  

(“错误17564992错误的结果修复了错误12999577现在我的   Oracle支持文档ID 17564992.8“)

它有它自己的补丁(补丁17564992,我们还没有测试过)但有一个解决方法(我们测试过):

alter session set "_fix_control" = '12999577:0';
alter session set "_optimizer_squ_bottomup"= FALSE;