SQL命令未正确结束

时间:2011-07-21 12:41:01

标签: sql oracle plsql ora-00933

SELECT /*+ PARALLEL(aae,4) */ DISTINCT nvl(aae.voucher_group_id,-1)  voucher_group_id,
                           aae.nominal_transaction_amount unit_price,
                           aae.original_currency_type currency_type,
                           aae.segmentation_id
             FROM air_account_events aae
            WHERE aae.time_hour_id >= m_start_thid
              AND aae.time_hour_id < m_end_thid
              AND aae.nominal_transaction_amount is not null 
           MINUS
           SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg) ahm
    ON (whm.voucher_group_id = ahm.voucher_group_id AND whm.unit_price = ahm.unit_price 
    AND whm.currency_type = ahm.currency_type AND whm.segmentation_id=ahm.segmentation_id) ahm

当我运行以下PL / SQL时,出现错误

         FROM wh_voucher_groups_dim vg) ahm
                                      *

第14行的错误: ORA-00933:SQL命令未正确结束

你可以指导哪里出错,还请指导改变


4 个答案:

答案 0 :(得分:2)

您在此行中缺少JOIN条件:

FROM wh_voucher_groups_dim vg) ahm
   JOIN ???????
   ON (whm.voucher_group_id ....

答案 1 :(得分:2)

编辑:根据您的评论 你可能正在寻找这个..?您需要在大括号中包含完整的内部查询,为其指定别名,然后将其连接到另一个表。无需使用“使用”。

select * from wh_voucher_groups_dim whm,
( SELECT /*+ PARALLEL(aae,4) */ 
         DISTINCT nvl(aae.voucher_group_id,-1)  voucher_group_id,
                           aae.nominal_transaction_amount unit_price,
                           aae.original_currency_type currency_type,
                           aae.segmentation_id
             FROM air_account_events aae
            WHERE aae.time_hour_id >= m_start_thid
              AND aae.time_hour_id < m_end_thid
              AND aae.nominal_transaction_amount is not null 
           MINUS
           SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg
 ) ahm
    WHERE  (whm.voucher_group_id = ahm.voucher_group_id AND 
            whm.unit_price = ahm.unit_price AND
            whm.currency_type = ahm.currency_type AND 
            whm.segmentation_id=ahm.segmentation_id)

您之前可能有ANSI连接语法,并在第二个查询中删除了该部分?

SELECT vg.voucher_group_id,
                  vg.unit_price,
                  vg.currency_type,
                  vg.segmentation_id
             FROM wh_voucher_groups_dim vg) ahm
    ON (whm.voucher_group_id = ahm.voucher_group_id AND 
        whm.unit_price = ahm.unit_price AND
        whm.currency_type = ahm.currency_type AND  
        whm.segmentation_id=ahm.segmentation_id) ahm

FROM wh_voucher_groups_dim vg)啊     ON(whm.voucher_group_id = ahm.voucher_group_id AND

这里是否有另一个表别名?

答案 2 :(得分:1)

要使用ON关键字,您需要在它之前加入。我在下面添加了JOIN关键字。您需要自己决定是否需要标准连接,外部,内部等。

             FROM wh_voucher_groups_dim vg) ahm JOIN <table>
    ON (whm.voucher_group_id = ahm.voucher_group_id AND whm.unit_price = ahm.unit_price 
    AND whm.currency_type = ahm.currency_type AND whm.segmentation_id=ahm.segmentation_id) ahm 

答案 3 :(得分:0)

我的猜测是,这是一个更大的查询的一部分,并以某种方式删除了开始部分:

SELECT ...                  --- missing part
FROM ...                    --- missing part
    sometable whm           --- missing part
        SOME JOIN           --- missing part
    (                       --- missing part

      SELECT /*+ PARALLEL(aae,4) */ DISTINCT ...
      ...
      FROM wh_voucher_groups_dim vg
    ) ahm
      ON ( whm.voucher_group_id = ahm.voucher_group_id 
       AND whm.unit_price = ahm.unit_price 
       AND whm.currency_type = ahm.currency_type 
       AND whm.segmentation_id=ahm.segmentation_id
         )