ORA-00907: 缺少右括号 00907. 00000 - “缺少右括号” *原因:*操作:行错误:44 列:30

Posted

技术标签:

【中文标题】ORA-00907: 缺少右括号 00907. 00000 - “缺少右括号” *原因:*操作:行错误:44 列:30【英文标题】:ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause: *Action: Error at Line: 44 Column: 30 【发布时间】:2015-07-08 06:14:20 【问题描述】:

我正在执行以下查询:

SELECT * 
FROM   (SELECT * 
        FROM   (SELECT DISTINCT r.llobjid   AS dataid, 
                                r.drawingid, 
                                r.revisionid, 
                                r.revisionnumber AS Revision_Number, 
                                r.revisionlabel, 
                                r.minorrevisionlabel, 
                                r.revisiontype, 
                                p.project AS Project, 
                                r.revisionstatus, 
                                r.r1i AS SignIn_Requestor, 
                                r.r2i AS SeedFileVersion, 
                                rt.display_type_name AS Revision_Type, 
                                rt.can_signin, 
                               rs.display_status_name AS Revision_Status, 
                                a.adntypeid, 
                                at.NAME AS ADN_Type, 
                                a.requestby, 
                                a.assignbyAS Assign_By_Id, 
                                ' '  AS Assign_By, 
                                a.assigndate, 
                                ' ' AS Assign_Date 
                FROM   adnids a 
                       INNER JOIN crt_revision r 
                               ON r.drawingid = a.adnid 
                                  AND Upper(a.wholeid) LIKE '4160%' 
                       INNER JOIN adntypes at 
                               ON a.adntypeid = at.adntypeid 
                                  AND at.orgunitid = 21 
                       INNER JOIN crt_project p 
                               ON r.projectid = p.projectid 
                                  AND p.ouid = 21 
                       LEFT OUTER JOIN crt_revision_type_map rt 
                                    ON r.revisiontype = rt.revtypeid 
                                       AND rt.ouid = 21 
                       LEFT OUTER JOIN crt_revision_status_map rs 
                                    ON r.revisionstatus = rs.revstatusid 
                                       AND rs.ouid = 21 
                WHERE  ( r.revisionstatus = 2 )) tbl1 
               INNER JOIN (SELECT DISTINCT d.dataid  AS LLDataID, 
                         Cast(d.dcomment AS NVARCHAR(4000)) AS 
                                           Title, 
                                           d.NAME  AS Document_Name, 
                                       d.createdate  AS  Created_Date, 
                                       d.modifydate  AS Modified_Date, 
                                           d.subtype, 
                                           d.versionnum, 
                                           d.permid, 
                                           d.reserved, 
                                           d.ownerid 
                           FROM   crt_revision r3 
                                  INNER JOIN adnids a3 
                                          ON r3.drawingid = a3.adnid 
                                      AND Upper(a3.wholeid) LIKE '4160%' 
                                  INNER JOIN dtree d 
                                          ON r3.llobjid = d.dataid 
                           WHERE  ( r3.revisionstatus = 2 )) tbl2 
                       ON tbl1.dataid = tbl2.lldataid 
               LEFT OUTER JOIN (SELECT DISTINCT l.dataid AS asm_dataid, 
                                                l.stateid, 
                                                l.intransition, 
                                               ls.NAME  AS Current_State, 
                                                ls.signin, 
                                                ls.lifecycleid, 
                                                ll.NAME  AS Lifecycle 
                                FROM   crt_revision r5 
                                       INNER JOIN adnids a5 
                                               ON r5.drawingid = a5.adnid 
                                    AND Upper(a5.wholeid) LIKE '4160%' 
                                       INNER JOIN lm_lifecycles l 
                                               ON l.dataid = r5.llobjid 
                                       INNER JOIN lm_def_states ls 
                                               ON l.stateid = ls.stateid 
                                       INNER JOIN lm_def_lifecycles ll 
                                               ON ls.lifecycleid = 
                                                  ll.lifecycleid 
                                WHERE  ( r5.revisionstatus = 2 )) tbl4 
                            ON tbl1.dataid = tbl4.asm_dataid 
        WHERE  ( EXISTS (SELECT b.dataid 
                         FROM   dtreeacl b 
                         WHERE  b.dataid = Nvl(tbl2.permid, tbl2.lldataid) 
                                AND ( rightid IN ( -2, -1, 1000, 1001 ) ) 
                                AND see > 0) ) 
        ORDER  BY modified_date DESC) tbl100 
WHERE  rownum <= 25

ORACLE SQL Developer 抛出错误为:ORA-00907: 缺少权利 括号

看起来一切都很好,但不明白我在哪里得到缺少右括号的错误。

【问题讨论】:

如果您使用的是sqldevelopper,建议您分别执行每个join语句,看看问题出在哪里。有时错误没有意义,因为您在括号结束前忘记了“as”或逗号。 17 左和 17 右路径。 我将查询复制到 SQL Developer 中,它给出了错误所在的行和列。 ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause: *Action: Error at Line: 42 Column: 53。这是Cast(d.dcomment AS NVARCHAR(4000))。似乎您在最后一个 NVARCHAR 转换时没有使用大小。删除 (4000)。 AT 至少在 ANSI SQL 中是保留字,将别名更改为其他名称,或双引号,即“at”。 Cast(d.dcomment AS NVARCHAR(4000)) NVARCHAR 还是 NVARCHAR2?还有 dcomment 的类型是什么? 【参考方案1】:

都是因为Cast(d.dcomment AS NVARCHAR(4000))。 NVARCHAR 不是有效的数据类型。

改成Cast(d.dcomment AS NVARCHAR2(2000))

会有用的

Fiddle

在小提琴中我的样本是

select Cast('ddd' AS NVARCHAR2(2000)) AS dd from dual

如果你把它改成

select Cast('ddd' AS NVARCHAR(2000)) AS dd from dual

你会得到错误

ORA-00907: 缺少右括号

Cast Operator in Oracle Tutorial

Data Types in Oracle

【讨论】:

以上是关于ORA-00907: 缺少右括号 00907. 00000 - “缺少右括号” *原因:*操作:行错误:44 列:30的主要内容,如果未能解决你的问题,请参考以下文章

ORA-00907: 缺少右括号 00907. 00000 - “缺少右括号” *原因:*操作:行错误:44 列:30

Django wagitail 后端 oracle 迁移 ORA-00907:缺少右括号

ORA-00907: 缺少右括号

ORA-00907: 缺少右括号 -- 奇怪

错误:ORA-00907:oracle 缺少右括号

请帮助解决“ORA-00907:缺少右括号”错误