什么可能导致以下 sql 出现 ORA-00936 - 缺少表达式?
我们看到以下 SQL 的错误消息 ORA-00936 Missing Expression:
请注意,这只是一个更大的 SQL 的简化版本,因此将其重写为内部联接或类似的内容实际上并不在此范围内:
这是失败的 SQL:
select (select count(*) from gt_roster where ROS_ROSTERPLAN_ID = RPL_ID)
from gt_rosterplan
where RPL_ID = 432065061
我尝试过的: * 提取最里面的 SQL 并替换外部 SQL 中的 ID,得到数字 12。 * 分别为子查询和 count(*) 起别名以及同时为两者起别名不会改变结果(即仍然是错误)
我还需要注意什么?
上面只是表,没有视图,RPL_ID是gt_rosterplan的主键,ROS_ROSTERPLAN_ID是该列的外键,这里基本上没有魔法或隐藏信息。
编辑:作为回答,不,您不需要此处的别名,因为列在表中具有唯一的命名。
已解决:问题是客户端运行了错误的客户端驱动程序版本 9.2.0.1,并且该版本存在已知问题。
We're seeing the error message ORA-00936 Missing Expression for the following SQL:
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:
This is the SQL that fails:
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)
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题在于客户端运行了错误的客户端驱动程序版本 9.2.0.1,并且该版本存在已知问题。
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.
假设列名不明确(即使是,也会导致不同的错误),这应该可行。 我运行了一个等效的语句并得到了没有错误的结果:
谷歌搜索似乎存在或已经存在导致 ORA-00936 错误的 Oracle 错误 - 请参阅 这个例如。
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:
Googling it appears that there are or have been Oracle bugs leading to ORA-00936 errors - see this for example.