今天同事提了一个问题,同样的SQL语句在有些地方执行是成功的,有些地方是失败的。
SQL如下:
SELECT (SELECT MIN(POST.post_name)
FROM org_post POST,
emp_station_change schange,
(SELECT basicinfo.organ_id, basicinfo.ppid
FROM ls_basicinfo basicinfo
WHERE basicinfo.emp_id = ls_employee.emp_id) emp
WHERE emp.organ_id = POST.dept_ppid
AND schange.emp_id = emp.ppid
AND schange.station_id = POST.post_id)
FROM ls_employee ls_employee
WHERE b0123 = '1'
AND b0126 = '1'
AND a0118 IN ('1', '2')
AND b5004 = '11'
AND ABS(MONTHS_BETWEEN(b5007, TO_DATE('2009-12-31', 'yyyy-mm-dd'))) < 12
AND (TO_DATE('2009-12-31', 'yyyy-mm-dd') - b5007) >= 0
AND b0126 = '1'
AND report_date = '2009-12'
黑体部分就是报ora-00904错的地方。
我们讨论了一下:
首先数据库版本都是10.2.0.1.0,平台有windows和aix,数据库有32位的和64位的。
最后经过验证找到了规律(不一定准确):
安装的是32位database的数据库是运行正常的,凡是64位的database都有报这个错。AIX平台都是64位的database,所以AIX都有这个错误。这个错误某些版本上是个bug需要对数据库进行升级。
there are some versions of Oracle 10.2.0.1 in which the parser does allow correlated
inline views to be parsed. However, this can lead to other problems further down the
line and should therefore not be used. In all patchsets 10.2.0.2 and higher this should
have been resolved and correlated inline views should once again return a ORA-904 error.
//搜索关键字:ora-00904 bug
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23135684/viewspace-625635/ ,如需转载,请注明出处,否则将追究法律责任。