ORA-00933: SQL 命令未正确结束
我尝试运行以下命令:
select *
from tax.tax_payer@reis tp
left outer join re_right@reis r on (tp.tin = r.tin or tp.tin = r.tin_a1 or tp.tin = r.tin_a2)
where (r.right_status = -1 or r.right_status is null)
--and r.right_id is not null
and tp.je_id = 12;
但不断得到
ORA-00933: SQL 命令未正确结束。
如果我删除评论,它就可以正常工作,但为什么呢?
I try to run the follow:
select *
from tax.tax_payer@reis tp
left outer join re_right@reis r on (tp.tin = r.tin or tp.tin = r.tin_a1 or tp.tin = r.tin_a2)
where (r.right_status = -1 or r.right_status is null)
--and r.right_id is not null
and tp.je_id = 12;
but keep getting
ORA-00933: SQL command not properly ended.
If I remove the comment it works fine but why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 .NET 中,查询中不能有尾随分号 - 它会搞砸查询。
In .NET, you can't have the trailing semi-colon on your query - it screws up the query.
上面的代码在 SQL*Plus 中完美运行,并在远程数据库连接中进行了适当的定义。在你的实际执行环境中一定存在一些令人困惑的软件。
尝试使用“内嵌注释”形式,而不是“直到行注释结束”。从风格上讲,不需要“;”除非您的执行环境需要它们,或者您正在提交多行程序代码块(这不是),否则应在 SQL 语句末尾添加。
此外,您可能希望将所有计算移至远程数据库中,而不是通过网络拉取数据并在更本地的数据库上进行联接。 (一些较新版本的 Oracle 将为您执行此优化。)
The above code works perfectly in SQL*Plus, with suitable definitions in the remote database connection. There must be some confounding piece of software in your actual execution environment.
Try using the "in-line comment" form, instead of the "until end of line comment". Stylistically there's no need for ";" at the end of SQL statements unless your execution environment needs them, or you are submitting a multi-line procedural block of code (which this is not).
Also, you may want to move all of the computations into the remote database instead of pulling the data across the wire and doing the joins on your more-local database. (Some more recent versions of Oracle will do this optimization for you.)