什么可能导致以下 sql 出现 ORA-00936 - 缺少表达式?

发布于 2024-07-08 07:33:08 字数 632 浏览 7 评论 0原文

我们看到以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掐死时间 2024-07-15 07:33:08

问题在于客户端运行了错误的客户端驱动程序版本 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.

愛放△進行李 2024-07-15 07:33:08

假设列名不明确(即使是,也会导致不同的错误),这应该可行。 我运行了一个等效的语句并得到了没有错误的结果:

SQL> select (select count(*) from emp2 where empdeptno = deptno)
  2  from dept
  3  where deptno=10
  4  /

(SELECTCOUNT(*)FROMEMP2WHEREEMPDEPTNO=DEPTNO)
---------------------------------------------
                                            3

谷歌搜索似乎存在或已经存在导致 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文