什么可能导致 ORA-00936 - 缺少以下 sql 的表达式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/249865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What could cause an ORA-00936 - Missing Expression with the following sql?
提问by Lasse V. Karlsen
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,并且该版本存在已知问题。
回答by Lasse V. Karlsen
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,并且该版本存在已知问题。
回答by Tony Andrews
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.

