ORA-00918错误列含糊不清

时间:2014-06-30 18:14:39

标签: plsql

我有以下LONG SQL产生上述错误。 我的环境是Oracle 11g 64位服务器,运行SQL Developer 4.0.2。 这是SQL:

CREATE or replace VIEW fw_contract_balances_query_v  
AS
SELECT SUM(s1_release.actual_applied_quantity) AS actual_applied,
       s1_contract_pricing_applied.actual_applied_quantity
                                               AS actual_applied_quantity,
       SUM(s1_release.allocated_quantity)      AS allocated,
       s1_contract.alt_basis_price             AS alt_basis_price,
       s1_contract.alt_futures_price           AS alt_futures_price,
       s1_contract.alt_price                   AS alt_price,
       s1_contract.alt_price_uom               AS alt_price_uom_code,
       s1_uom_alt.description                  AS alt_price_uom_description,
       s1_contract.alternate_ship_mode_code    AS alt_ship_mode_code,
       alt_ship_mode.description               AS alt_ship_mode_description,
       s1_contract.alt_unit_value              AS alt_unit_value,
       broker_naa.full_name                    AS broker_full_name,
       s1_contract.broker_id                   AS broker_id,
       broker_naa.short_name                   AS broker_short_name,
       s1_commodity.buying_uom_code            AS buying_uom_code,
       s1_uom_buy.description                  AS buying_uom_description,
       s1_contract.change_date                 AS change_date,
       s1_contract.commodity_id                AS commodity_id,
       s1_commodity_lang.name                  AS commodity_name,
       s1_contract.commodity_note_code         AS commodity_note_code,
       s1_contract_type.company_owned_flag     AS company_owned_flag,
       s1_contract.confirm_pricing_flag        AS confirm_pricing_flag,
       s1_contract.contract_date               AS contract_date,
       s1_contract.contract_format_code        AS contract_format_code,
       s1_contract.grade                       AS contract_grade,
       s1_contract.grade_govern_nbr            AS contract_grade_govern_nbr,
       s1_contract.contract_id                 AS contract_id,
       s1_contract.contract_nbr                AS contract_no,
       s1_contract.quantity                    AS contract_quantity,
       s1_contract.contract_reference          AS contract_reference,
       s1_contract.contract_status             AS contract_status_code,
       s1_contract_status.description          AS contract_status_description,
       s1_contract.contract_type               AS contract_type_code,
       CASE COALESCE(s1_contract.contract_type,'')
            WHEN 'P/C' THEN 'Purchase'
            WHEN 'S/C' THEN 'Sales'
            ELSE 'Other'
       END                                     AS contract_type_description,
       s1_uom_conv_10000.conv_factor           AS conv_factor,
       cps_program_type_lang.description       AS cps_type_description,
       s1_contract.currency_code               AS currency_code,
       s1_currency_lang.description            AS currency_description,
       vendor_naa.full_name                    AS customer_full_name,
       vendor_naa.name_and_address_id          AS customer_no,
       vendor_naa.short_name                   AS customer_short_name,
       delivery_naa.full_name                  AS delivery_point_full_name,
       s1_contract.delivery_point_id           AS delivery_point_id,
       delivery_naa.short_name                 AS delivery_point_short_name,
       SUM(s1_release.estimated_applied_quantity)
                                               AS estimated_applied,
       s1_contract_pricing_applied.estimated_applied_quantity
                                               AS estimated_applied_quantity,
       s1_contract.fob_point                   AS fob_point,
       s1_freight_term.code                    AS freight_term_code,
       s1_contract.freight_term_serial_nbr     AS freight_term_serial_nbr,
       s1_uom_conv_10000.from_nbr_of_decimals  AS from_nbr_of_decimals,
       s1_contract.hold_flag                   AS hold_flag,
       s1_contract.iv_pricing_point_code       AS iv_pricing_point_code,
       s1_contract.load_based_flag             AS load_based_flag,
       COALESCE(vp.quantity * s1_uom_conv_10000.conv_factor / 10000,0)
                                               AS loadout,
       location_naa.full_name                  AS location_full_name,
       s1_contract.plc_id                      AS location_id,
       location_naa.short_name                 AS location_short_name,
       s1_contract.market_month                AS market_month,
       s1_contract.market_zone_frt_adj         AS market_zone_frt_adj,
       s1_contract.misc_column_description1    AS misc_column_description1,
       s1_contract.misc_column_description2    AS misc_column_description2,
       s1_contract.misc_column_description3    AS misc_column_description3,
       s1_contract.misc_column_description4    AS misc_column_description4,
       s1_contract.misc_column_description5    AS misc_column_description5,
       s1_contract.misc_column_description6    AS misc_column_description6,
       s1_contract.misc_column_description7    AS misc_column_description7,
       s1_contract.misc_column_description8    AS misc_column_description8,
       s1_contract.number_of_loads             AS number_of_loads,
       s1_contract.od_description              AS od_description,
       s1_contract.price                       AS price,
       s1_contract.price_basis                 AS price_basis,
       s1_contract.price_future                AS price_future,
       s1_contract.pricing_status_code         AS pricing_status_code,
       s1_pricing_status_lang.description      AS pricing_status_description,
       s1_contract.pricing_type_code           AS pricing_type_code,
       s1_contract_type_lang.description       AS pricing_type_description,
       s1_contract.printed_flag                AS printed_flag,
       cps_program_category_lang.code          AS program_category_code,
       cps_program_category_lang.description   AS program_category_description,
       cps_program_schedule.commodity_id       AS program_commodity,
       cps_program_schedule.serial_nbr         AS program_id,
       cps_program_schedule.name               AS program_name,
       cps_program_type_lang.code              AS program_type_code,
       cps_program_offer_type_lang.description AS program_type_description,
       cps_program_year_lang.code              AS program_year_code,
       cps_program_schedule.year_code          AS program_year_description,
       s1_region_lang.description              AS region_description,
       s1_contract.sched_ship_end_date         AS sched_ship_end_date,
       s1_contract.sched_ship_start_date       AS sched_ship_start_date,
       s1_contract.schedule_code               AS schedule_code,
       SUM(s1_release.quantity)                AS scheduled,
       s1_commodity.selling_uom_code           AS selling_uom_code,
       s1_uom_sel.description                  AS selling_uom_description,
       s1_region_lang.serial_nbr               AS serial_nbr,
       settled.settled_qty                     AS settled_qty,
       s1_contract.settlement_eligible_flag    AS settlement_eligible_flag,
       s1_contract.ship_mode_code              AS ship_mode_code,
       ship_mode_lang.description              AS ship_mode_description,
       ship_to_naa.full_name                   AS ship_to_full_name,
       s1_contract.ship_to_id                  AS ship_to_id,
       ship_to_naa.short_name                  AS ship_to_short_name,
       s1_contract.shipment_note               AS shipment_note,
       s1_contract.signed_flag                 AS signed_flag,
       s1_contract_type.special_contract_type  AS special_contract_type,
       s1_commodity.storage_uom_code           AS storage_uom_code,
       s1_uom_str.description                  AS storage_uom_description,
       s1_uom_conv_10000.to_nbr_of_decimals    AS to_nbr_of_decimals,
       s1_uom_conv_10000.to_uom                AS to_uom_code,
       s1_uom_to.description                   AS to_uom_description,
       s1_trader.initials                      AS trader_initials,
       s1_contract.trader_id                   AS trader_id,
       s1_trader.name                          AS trader_name,
       (COALESCE(s1_contract_pricing_applied.tbd_quantity,0)
        + COALESCE(s1_contract_pricing_applied.basis_quantity,0)
        + COALESCE(s1_contract_pricing_applied.futures_quantity,0)
       )                                       AS unpriced_quantity,
       s1_contract.quantity_uom                AS uom_code,
       s1_uom_qty.description                  AS uom_description,
       s1_commodity_vehicle.vehicle_code       AS vehicle_code,
       s1_vehicle_lang.description             AS vehicle_description,
       SUM(s1_release.wash_quantity)           AS washed,
       s1_contract.weight_govern_nbr           AS weight_govern_nbr
  FROM s1_contract
       LEFT OUTER JOIN s1_name_and_address vendor_naa
         ON s1_contract.vendor_customer_id = vendor_naa.name_and_address_id
       LEFT OUTER JOIN s1_name_and_address ship_to_naa
         ON s1_contract.ship_to_id = ship_to_naa.name_and_address_id
       LEFT OUTER JOIN s1_trader
         ON s1_contract.trader_id = s1_trader.trader_id
       LEFT OUTER JOIN s1_contract_status
         ON s1_contract.contract_status = s1_contract_status.contract_status
       LEFT OUTER JOIN s1_name_and_address broker_naa
         ON s1_contract.broker_id = broker_naa.name_and_address_id
       LEFT OUTER JOIN s1_contract_type
         ON s1_contract.pricing_type_code = s1_contract_type.contract_type_code
       LEFT OUTER JOIN s1_contract_type_lang
         ON s1_contract.pricing_type_code = s1_contract_type_lang.contract_type_code
       LEFT OUTER JOIN s1_pricing_status_lang
         ON s1_contract.pricing_status_code = s1_pricing_status_lang.pricing_status_code
       LEFT OUTER JOIN s1_commodity_vehicle
         ON s1_contract.commodity_id = s1_commodity_vehicle.commodity_id
        AND s1_contract.delivery_vehicle_code = s1_commodity_vehicle.commodity_vehicle_code
       LEFT OUTER JOIN s1_origin_destination
         ON s1_contract.od_description = s1_origin_destination.description
       LEFT OUTER JOIN s1_region_lang
         ON s1_origin_destination.region_serial_nbr = s1_region_lang.serial_nbr
       LEFT OUTER JOIN s1_freight_term
         ON s1_contract.freight_term_serial_nbr = s1_freight_term.serial_nbr
       LEFT OUTER JOIN s1_vehicle_lang
         ON s1_commodity_vehicle.vehicle_code = s1_vehicle_lang.vehicle_code
       LEFT OUTER JOIN s1_currency_lang
         ON s1_contract.currency_code = s1_currency_lang.currency_code
       JOIN s1_commodity
         ON s1_contract.commodity_id = s1_commodity.commodity_id
       JOIN s1_commodity_lang
         ON s1_contract.commodity_id = s1_commodity_lang.commodity_id
       LEFT OUTER JOIN s1_name_and_address delivery_naa
         ON s1_contract.delivery_point_id = delivery_naa.name_and_address_id
       LEFT OUTER JOIN
            (SELECT SUM(a.vp_applied_quantity) AS settled_qty,
                    a.contract_nbr AS contract_nbr1
               FROM s1_settlement_ticket_detail a,
                    s1_settlement b
              WHERE a.settlement_nbr = b.settlement_nbr
                AND b.status_code IN ('N','S','C','R','B')
                AND a.deleted_flag = 'N'
              GROUP BY a.contract_nbr
            ) settled
         ON settled.contract_nbr1 = s1_contract.contract_nbr
       LEFT OUTER JOIN s1_uom_lang s1_uom_alt
         ON s1_contract.alt_price_uom = s1_uom_alt.uom_code
       LEFT OUTER JOIN s1_uom_lang s1_uom_qty
         ON s1_contract.quantity_uom = s1_uom_qty.uom_code
       LEFT OUTER JOIN cps_program_schedule
         ON s1_contract.program_schedule_serial_nbr = cps_program_schedule.serial_nbr
        AND s1_contract.plc_id = cps_program_schedule.plc_id
       LEFT OUTER JOIN cps_program_type_lang
         ON cps_program_schedule.type_code = cps_program_type_lang.code
       LEFT OUTER JOIN cps_program_category_lang
         ON cps_program_schedule.category_code = cps_program_category_lang.code
       LEFT OUTER JOIN cps_program_year_lang
         ON cps_program_schedule.year_code = cps_program_year_lang.code
       LEFT OUTER JOIN cps_program_offer_type_lang
         ON cps_program_schedule.offer_code = cps_program_offer_type_lang.code
       LEFT OUTER JOIN
            (SELECT s1_vehicle_processing.contract_nbr,
                    SUM(s1_quantity_entry.scale_quantity_lb *
                        CASE WHEN s1_vehicle_processing.applied_type = 'S'
                                 THEN s1_vehicle_processing.scale_quantity / s1_quantity_entry.scale_quantity_lb
                                 ELSE s1_vehicle_processing.report_quantity / COALESCE(s1_quantity_entry.report_quantity_lb,s1_quantity_entry.scale_quantity_lb)
                         END)                  AS quantity
               FROM s1_quantity_entry,
                    s1_vehicle_processing
              WHERE s1_vehicle_processing.quantity_entry_nbr = s1_quantity_entry.quantity_entry_nbr
                AND s1_quantity_entry.scale_ticket_inbound_outbound = 'O'
              GROUP BY s1_vehicle_processing.contract_nbr
            ) vp
         ON s1_contract.contract_nbr = vp.contract_nbr
       LEFT OUTER JOIN s1_ship_mode_lang ship_mode_lang
         ON s1_contract.ship_mode_code = ship_mode_lang.ship_mode_code
       LEFT OUTER JOIN s1_ship_mode_lang alt_ship_mode
         ON s1_contract.alternate_ship_mode_code = alt_ship_mode.ship_mode_code,
       s1_commodity
       LEFT OUTER JOIN s1_uom_lang s1_uom_buy
         ON s1_commodity.buying_uom_code = s1_uom_buy.uom_code
       LEFT OUTER JOIN s1_uom_lang s1_uom_sel
         ON s1_commodity.selling_uom_code = s1_uom_sel.uom_code
       LEFT OUTER JOIN s1_uom_lang s1_uom_str
         ON s1_commodity.storage_uom_code = s1_uom_str.uom_code,
       s1_uom_conv_10000
       LEFT OUTER JOIN s1_uom_lang s1_uom_to
         ON s1_uom_conv_10000.to_uom = s1_uom_to.uom_code,
       s1_contract_pricing_applied,
       s1_name_and_address location_naa,
       s1_release
 WHERE s1_contract.commodity_id = s1_commodity.commodity_id
   AND s1_contract.quantity_uom = s1_uom_conv_10000.from_uom
   AND s1_contract_pricing_applied.contract_nbr = s1_contract.contract_nbr
   AND s1_contract.plc_id = location_naa.name_and_address_id
   AND s1_release.contract_nbr = s1_contract.contract_nbr
   AND ((s1_uom_conv_10000.commodity_id IS NULL) OR
        (s1_uom_conv_10000.commodity_id = s1_commodity.commodity_id)
       )
   AND ((s1_contract.contract_type = 'P/C' AND
         s1_commodity.buying_uom_code = s1_uom_conv_10000.to_uom
        ) OR
        (s1_contract.contract_type = 'S/C' AND
         s1_commodity.selling_uom_code = s1_uom_conv_10000.to_uom
        ) OR
        (s1_contract.contract_type <> 'S/C' AND
         s1_contract.contract_type <> 'P/C' AND
         s1_commodity.storage_uom_code = s1_uom_conv_10000.to_uom
        )
       )
 GROUP BY alt_ship_mode.description,
          broker_naa.full_name,
          broker_naa.short_name,
          cps_program_category_lang.code,
          cps_program_category_lang.description,
          cps_program_offer_type_lang.description,
          cps_program_schedule.commodity_id,
          cps_program_schedule.name,
          cps_program_schedule.serial_nbr,
          cps_program_schedule.year_code,
          cps_program_type_lang.code,
          cps_program_type_lang.description,
          cps_program_year_lang.code,
          cps_program_year_lang.description,
          delivery_naa.full_name,
          delivery_naa.short_name,
          location_naa.full_name,
          location_naa.short_name,
          s1_commodity.buying_uom_code,
          s1_commodity_lang.name,
          s1_commodity.selling_uom_code,
          s1_commodity.storage_uom_code,
          s1_commodity_vehicle.vehicle_code,
          s1_contract.alt_basis_price,
          s1_contract.alt_futures_price,
          s1_contract.alt_price,
          s1_contract.alt_price_uom,
          s1_contract.alt_unit_value,
          s1_contract.alternate_ship_mode_code,
          s1_contract.broker_id,
          s1_contract.change_date,
          s1_contract.commodity_id,
          s1_contract.commodity_id,
          s1_contract.commodity_note_code,
          s1_contract.confirm_pricing_flag,
          s1_contract.contract_date,
          s1_contract.contract_format_code,
          s1_contract.contract_id,
          s1_contract.contract_nbr,
          s1_contract.contract_reference,
          s1_contract.contract_status,
          s1_contract.contract_type,
          s1_contract.currency_code,
          s1_contract.delivery_point_id,
          s1_contract.fob_point,
          s1_contract.freight_term_serial_nbr,
          s1_contract.grade,
          s1_contract.grade_govern_nbr,
          s1_contract.hold_flag,
          s1_contract.iv_pricing_point_code,
          s1_contract.load_based_flag,
          s1_contract.market_month,
          s1_contract.market_zone_frt_adj,
          s1_contract.misc_column_description1,
          s1_contract.misc_column_description2,
          s1_contract.misc_column_description3,
          s1_contract.misc_column_description4,
          s1_contract.misc_column_description5,
          s1_contract.misc_column_description6,
          s1_contract.misc_column_description7,
          s1_contract.misc_column_description8,
          s1_contract.number_of_loads,
          s1_contract.od_description,
          s1_contract.plc_id,
          s1_contract.price,
          s1_contract.price_basis,
          s1_contract.price_future,
          s1_contract.pricing_status_code,
          s1_contract.pricing_type_code,
          s1_contract.printed_flag,
          s1_contract.quantity,
          s1_contract.quantity_uom,
          s1_contract.sched_ship_end_date,
          s1_contract.sched_ship_start_date,
          s1_contract.schedule_code,
          s1_contract.settlement_eligible_flag,
          s1_contract.ship_mode_code,
          s1_contract.ship_to_id,
          s1_contract.shipment_note,
          s1_contract.signed_flag,
          s1_contract.trader_id,
          s1_contract.trader_id,
          s1_contract.vendor_customer_id,
          s1_contract.weight_govern_nbr,
          s1_contract_pricing_applied.actual_applied_quantity,
          s1_contract_pricing_applied.basis_quantity,
          s1_contract_pricing_applied.estimated_applied_quantity,
          s1_contract_pricing_applied.futures_quantity,
          s1_contract_pricing_applied.tbd_quantity,
          s1_contract_status.description,
          s1_contract_type.company_owned_flag,
          s1_contract_type_lang.description,
          s1_contract_type.special_contract_type,
          s1_currency_lang.description,
          s1_freight_term.code,
          s1_pricing_status_lang.description,
          s1_region_lang.description,
          s1_region_lang.serial_nbr,
          s1_release.contract_nbr,
          s1_trader.initials,
          s1_trader.name,
          s1_uom_alt.description,
          s1_uom_buy.description,
          s1_uom_conv_10000.conv_factor,
          s1_uom_conv_10000.from_nbr_of_decimals,
          s1_uom_conv_10000.to_nbr_of_decimals,
          s1_uom_conv_10000.to_uom,
          s1_uom_qty.description,
          s1_uom_sel.description,
          s1_uom_str.description,
          s1_uom_to.description,
          s1_vehicle_lang.description,
          settled.settled_qty,
          ship_mode_lang.description,
          ship_to_naa.full_name,
          ship_to_naa.short_name,
          vendor_naa.full_name,
          vendor_naa.name_and_address_id,
          vendor_naa.short_name,
          vp.quantity
/

这是错误: 命令行出错:266列:11 错误报告 - SQL错误:ORA-00918:列模糊定义 00918. 00000 - &#34;列模糊定义&#34; *原因:
*操作:

以上错误非常模糊:它指向的行是:           s1_commodity.storage_uom_code, 我不相信是相关的。

任何帮助将不胜感激。 默里

1 个答案:

答案 0 :(得分:1)

heyyo,它的“大小”没有问题,但语法。把它放入记事本++或其他什么, 慢慢滚动到JOIN。是否允许逗号和表名附近的关键字段?我从来没有见过那个:),这可能是真正的问题,但甲骨文并不总是知道这一点。 :)明确错误并继续。 顺便问一下,是MySQL吗? ,允许(逗号的东西),但你不能用逗号和常规JOIN在一个语句中混合

问候