【问题标题】:Oracle: SQL not properly endedOracle:SQL 未正确结束
【发布时间】:2015-01-02 05:11:41
【问题描述】:

我正在尝试在 grails 中运行此 sql 查询。但是得到 SQL 没有正确结束的错误。

def sessionFactory    
final session = sessionFactory.currentSession;
final  String query  = 'select count(A.id) from Artifact as A LEFT JOIN classification as C on (A.id=C.artifact_id) where C.id IS NULL';
final sqlQuery = session.createSQLQuery(query);

def totalunclass =  sqlQuery.with {
                            addEntity(Artifact);                            
                            }

【问题讨论】:

  • 在末尾试试分号,也许?

标签: oracle hibernate grails


【解决方案1】:
final  String query  = 'select count(A.id) as ct from Artifact A 
                       LEFT JOIN classification C on (A.id=C.artifact_id)
                        where C.id IS NULL';

Oracle 只是不喜欢 AS 关键字作为表名的别名,所以删除它。

【讨论】:

  • 它应该返回我的计数吧?但其在位置 1157 处的意外标记 END OF FILE。
  • SQL 查询目前不支持返回别名
  • 对不起,我不是 grails 人,SQL 错误现在消失了吗?
  • 您仍然可以将 别名 添加到您的 count()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-10
  • 1970-01-01
  • 2018-10-25
  • 2016-09-21
相关资源
最近更新 更多