We're seeing the error message ORA-00936 Missing Expression for the following SQL:
我们看到以下SQL的错误消息ORA-00936 Missing Expression:
Note that this is just a cut-down version of a much bigger SQL so rewriting it to a inner join or similar is not really in the scope of this:
请注意,这只是一个更大的SQL的缩减版本,因此将其重写为内部联接或类似的实际上不在此范围内:
This is the SQL that fails:
这是失败的SQL:
select (select count(*) from gt_roster where ROS_ROSTERPLAN_ID = RPL_ID)
from gt_rosterplan
where RPL_ID = 432065061
What I've tried: * Extracting the innermost SQL and substituting the ID from the outer SQL gives me the number 12. * Aliasing both the sub-query, and the count(*) individually and both at the same time does not change the outcome (ie. still an error)
我尝试过:*提取最里面的SQL并替换外部SQL中的ID给出了数字12. *单独对子查询和计数(*)进行别名并且两者同时不会改变结果(即仍然是一个错误)
What else do I need to look at?
还有什么我需要看的?
The above are only tables, no views, RPL_ID is primary key of gt_rosterplan, and ROS_ROSTERPLAN_ID is a foreign key to this column, there is basically no magic or hidden information here.
以上只是表,没有视图,RPL_ID是gt_rosterplan的主键,而ROS_ROSTERPLAN_ID是这个列的外键,这里基本上没有魔法或隐藏信息。
Edit: In response to answer, no, you do not need the aliases here as the columns are uniquely named across the tables.
编辑:响应答案,不,您不需要此处的别名,因为列在表中唯一命名。
Solved: The problem was that the client was running the wrong client driver version, 9.2.0.1, and there are known problems with that version.
解决:问题是客户端运行了错误的客户端驱动程序版本9.2.0.1,并且该版本存在已知问题。
2 个解决方案
#1
1
That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different error). I ran an equivalent statement and got a result without error:
这应该有效,假设列名称不明确(即使它们会导致不同的错误)。我运行了一个等效语句并得到了一个没有错误的结果:
SQL> select (select count(*) from emp2 where empdeptno = deptno)
2 from dept
3 where deptno=10
4 /
(SELECTCOUNT(*)FROMEMP2WHEREEMPDEPTNO=DEPTNO)
---------------------------------------------
3
Googling it appears that there are or have been Oracle bugs leading to ORA-00936 errors - see this for example.
谷歌搜索似乎有或有一些导致ORA-00936错误的Oracle错误 - 例如,请参阅此处。
#2
3
The problem was that the client was running the wrong client driver version, 9.2.0.1, and there are known problems with that version.
问题是客户端运行了错误的客户端驱动程序版本9.2.0.1,并且该版本存在已知问题。
#1
1
That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different error). I ran an equivalent statement and got a result without error:
这应该有效,假设列名称不明确(即使它们会导致不同的错误)。我运行了一个等效语句并得到了一个没有错误的结果:
SQL> select (select count(*) from emp2 where empdeptno = deptno)
2 from dept
3 where deptno=10
4 /
(SELECTCOUNT(*)FROMEMP2WHEREEMPDEPTNO=DEPTNO)
---------------------------------------------
3
Googling it appears that there are or have been Oracle bugs leading to ORA-00936 errors - see this for example.
谷歌搜索似乎有或有一些导致ORA-00936错误的Oracle错误 - 例如,请参阅此处。
#2
3
The problem was that the client was running the wrong client driver version, 9.2.0.1, and there are known problems with that version.
问题是客户端运行了错误的客户端驱动程序版本9.2.0.1,并且该版本存在已知问题。