-3

SQL を初めて使用するので、クエリを実行しようとすると「エラー - ORA-00907: 右括弧がありません」というエラーが表示されます。この問題の解決を手伝ってください。以下のクエリを見つけてください。よろしくお願いします!

(SELECT
        DISTINCT d.order_key ord,
        d.order_status stat,
        m.order_call_key,
        m.opr_no opr_no,
        m.opr_step_no opr_step_no 
    FROM
        owi_order d,
        order_call m 
    WHERE
        d.rev_status = 'Complete' 
        AND d.order_type_cd <> 'ADPPO' 
        AND UPPER(d.pgm_id) = UPPER ('777') 
        AND (UPPER(m.init_callbrd_action_cd) IN ('MGWP', 'QWIP', 'RFI', 'RIOT', 'RIPI', 'RIR', 'RJSS', 'RNCR', 'RQAI', 'RSIR', 'RTQA') 
        OR (UPPER(m.cmpl_callbrd_action_cd) IN ('MGWP', 'QWIP', 'RFI', 'RIOT', 'RIPI', 'RIR', 'RJSS', 'RNCR', 'RQAI', 'RSIR', 'RTQA') 
        OR EXISTS  ( SELECT
            'x' 
        from
            order_call_ack a 
        where
            a.order_call_key=m.order_call_key 
            AND UPPER(a.ackd_callbrd_action_cd) IN ('MGWP', 'QWIP', 'RFI', 'RIOT', 'RIPI', 'RIR', 'RJSS', 'RNCR', 'RQAI', 'RSIR', 'RTQA') 
            AND a.active_ind <> 'N')) 
        and m.order_key = d.order_key), related_query AS ((SELECT
            s.related_order_key ord,
            s.order_key parent,
            b.order_call_key call_parent,
            o.order_call_key call 
        FROM
            related_obj s,
            owi_rep_query b,
            owi_order t,
            order_call o 
        WHERE
            s.order_key=b.ord 
            AND s.related_order_key = o.order_key 
            AND b.stat  IN ('Enqueued','Scheduled','Pulled') 
            AND s.related_obj_stat_cd <> 'DL' 
            AND s.related_order_key = t.order_key 
            AND t.rev_status IN ('Complete')  
            AND b.order_call_key <> o.order_call_key 
        UNION
        SELECT
            ord,
            to_number(null) parent,
            to_number(null) call_parent,
            order_call_key call 
        from
            owi_rep_query)), related_call_query AS (SELECT
        distinct ord,
        parent,
        MAX(call_parent) call_parent,
        call,
        (SELECT
            CASE m.call_status_nm  
                WHEN 'Completed' THEN m.cmpl_callbrd_action_cd 
                ELSE (SELECT
                    DISTINCT ackd_callbrd_action_cd 
                FROM
                    order_call_ack ock,
                    order_call ocaa 
                WHERE
                    ock.order_call_key = r.call 
                    AND ocaa.order_call_key = r.call 
                    AND ocaa.call_status_nm <> 'Completed' 
                    AND ock.ack_ts = (SELECT
                        MAX(ack_ts) 
                    FROM
                        order_call_ack t 
                    WHERE
                        t.order_call_key = ocaa.order_call_key 
                        AND t.active_ind <> 'N')) 
                END 
            FROM
                Order_call m 
            WHERE
                m.order_call_key = r.call) call_action 
        FROM
            related_query r 
        GROUP BY
            ord,
            parent,
            call),
            temp_rslt AS (SELECT
                RPAD(d.order_id,
                32,
                ' ') orderRecordIdTemp,
                TRIM(RPAD(m.acc_cd,
                3,
                ' '))||'/'||TRIM(RPAD(m.acc_pos_cd,
                3,
                ' '))||'/'|| RPAD(DECODE(m.work_loc_cd,
                '..',
                '',
                '...',
                '',
                m.work_loc_cd),
                3,
                ' ') accPosWl,
                LPAD(m.line_no,
                5,
                0) lineNumber,
                RPAD(m.call_id,
                8,
                ' ') callIdVal,
                RPAD(m.order_hld_ind,
                4,
                ' ') orderHldInd,
                RPAD(m.prty_no,
                4,
                ' ') prtyNo,
                RPAD(TO_CHAR(m.call_init_ts,
                'MM/DD HH24:MI'),
                11,
                ' ') callInitTs,
                RPAD(call_action,
                4,
                ' ') callAction,
                RPAD(TO_CHAR(m.ecd,
                'MM/DD HH24:MI'),
                11,
                ' ') ecdVal,
                RPAD(F_SUBPIPES(SUBSTR(REPLACE(NVL(m.remark_txt,
                TO_CLOB(' ')),
                '',
                ' '),
                1,
                40)),
                11,
                ' ') remarkTxt,
                LPAD(TRIM(m.order_call_key),
                40,
                ' ') orderCallKey,
                NVL(call_parent,
                0) call_parent,
                LPAD(a.parent,
                40,
                ' ') rel_key,
                d.order_key order_key,
                RPAD(m.prty_no,
                38,
                ' ') prty_no,
                RPAD(m.call_id,
                10,
                ' ') call_id,
                TRIM(RPAD(m.acc_cd,
                4,
                ' '))||'/'||TRIM(RPAD(m.acc_pos_cd,
                5,
                ' '))||'/'|| RPAD(DECODE(m.work_loc_cd,
                '..',
                '',
                '...',
                '',
                m.work_loc_cd),
                3,
                ' ') acc_pos_wl,
                RPAD(TO_CHAR(m.call_init_ts,
                'MM/DD/YYYY HH24:MI'),
                20,
                ' ') call_init_ts,
                m.opr_no opr_no,
                m.opr_step_no opr_step_no 
            FROM
                owi_order d,
                order_call m,
                related_call_query a 
            WHERE
                m.order_key=d.order_key 
                AND a.ord = d.order_key 
                AND m.order_call_key = a.call 
                AND m.init_callbrd_action_cd <> 'WIP') SELECT
                RPAD(LPAD(' ',
                (level - 1) * 2) || orderRecordIdTemp,
                32,
                ' ') orderRecordId,
                accPosWl,
                lineNumber,
                callIdVal,
                orderHldInd,
                prtyNo,
                callInitTs,
                callAction,
                ecdVal,
                remarkTxt,
                orderCallKey 
            from
                temp_rslt CONNECT 
            BY
                PRIOR orderCallKey = call_parent 
                AND PRIOR Order_key = rel_key START WITH orderCallKey IN (SELECT
                    b.orderCallKey 
                FROM
                    temp_rslt b 
                WHERE
                    NOT EXISTS (SELECT
                        'X' 
                    FROM
                        temp_rslt v 
                    WHERE
                        v.order_key = b.rel_key) 
                    AND (SELECT
                        COUNT(g.orderCallKey) 
                    from
                        temp_rslt g 
                    WHERE
                        g.orderCallKey = b.orderCallKey) = 1)  
                ORDER SIBLINGS BY
                    prtyNo,
                    callInitTs,
                    orderRecordIdTemp,
                    callIdVal,
                    orderCallKey

編集 1: コードタグを追加しました!

4

1 に答える 1

1

@user2392549 : Oracle サイトから SQLDeveloper をダウンロードして使用します。これはフリーウェアであり、さまざまなスタイルの優れた書式設定オプションを提供します。クエリを適切にフォーマットし、不足している括弧をデバッグする必要があります。また、SQL Developerには、タイプミスまたは実行中に問題が発生している行番号を示すという利点があります。

ダウンロードリンク: http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

于 2013-05-20T22:22:09.787 に答える