1

我尝试运行以下命令:

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 命令未正确结束。

如果我删除评论它工作正常,但为什么呢?

4

2 回答 2

6

上面的代码在 SQL*Plus 中完美运行,在远程数据库连接中有合适的定义。在您的实际执行环境中必须有一些令人困惑的软件。

尝试使用“行内注释”表单,而不是“直到行尾注释”。从风格上讲,不需要“;” 在 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 tp.je_id = 12
 /* and r.right_id is not null */

此外,您可能希望将所有计算转移到远程数据库中,而不是通过网络拉取数据并在更本地的数据库上进行连接。(一些更新的 Oracle 版本会为您进行这种优化。)

于 2011-03-23T19:00:07.043 回答
2

在 .NET 中,您的查询不能有尾随分号 - 它搞砸了查询。

于 2011-03-23T19:48:37.987 回答