【问题标题】:SQL Query Builder in Visual Studio 2019 does not read PL/SQLVisual Studio 2019 中的 SQL 查询生成器不读取 PL/SQL
【发布时间】:2022-01-17 12:32:10
【问题描述】:

我尝试在 Visual Studio 2019 的 SQL Query Builder 中运行 PL/SQL 查询,不幸的是,Visual Studio 2019 中的 SQL Query Builder 似乎只能从 Microsoft SQL Server 读取 T-SQL。

这是我来自 Oracle 的 PL/SQL 查询:

    SELECT
   rct.trx_number Invoice_Number,
   rct.trx_date Sold_Date,
   NULL Reporting_Partner_Branch_ID,
   NULL RP_Branch_Address_1,
   NULL RP_Branch_Address_2,
   NULL RP_Branch_City,
   NULL RP_Branch_State_Province,
   NULL RP_Branch_Postal_Code,
   NULL RP_Branch_Country_Code,
   NULL Bill_To_Customer_ID,
   rct.su_bill_to_location Bill_To_Customer_Name,
   rct.raa_bill_to_address1 Bill_To_Address_1,
   rct.raa_bill_to_address2 Bill_To_Address_2,
   rct.raa_bill_to_city Bill_To_City,
   rct.raa_bill_to_province Bill_To_State_Province,
   rct.raa_bill_to_postal_code Bill_To_Postal_Code,
   NULL Tax_ID_VAT,
   NULL Ship_To_Customer_ID,
   rct.su_bill_to_location Ship_To_Customer_Name,
   rct.raa_ship_to_address1 Ship_To_Address_1,
   rct.raa_ship_to_address2 Ship_To_Address_2,
   rct.raa_ship_to_city Ship_To_City,
   rct.raa_ship_to_province Ship_To_State_Province,
   rct.raa_ship_to_postal_code Ship_To_Postal_Code,
   NULL Quote_ID,
   mmpn.mfg_part_num Schneider_Electric_SKU,
   NULL Schneider_Electric_ISX_ID,
   msib.description SE_SKU_Description,
   NULL EAN_UPC_Code,
   NULL Reporting_Partner_Part_Number,
   NULL SE_Product_Serial_Numbers,
   rctla.quantity_invoiced Quantity,
   rctla.unit_selling_price Unit_Price,
   rct.invoice_currency_code Currency_Code,
   CASE
      WHEN rct.ctt_type_name = 'Online Channels CM'
      AND ottt.name NOT LIKE '%Return%' THEN 0
      WHEN rctla.DESCRIPTION IN (
         '24.Commission',
         '24.Fulfillment Fees',
         '24.Payment Fees'
      ) THEN 0
      WHEN rctla.INTERFACE_LINE_ATTRIBUTE11 <> 0 THEN 0
      WHEN rct.created_from = 'AR_CREDIT_MEMO_API'
      AND rct.batch_source_id = 2001 THEN 0
      ELSE (
         DECODE (
            rct.bs_batch_source_name,
            'MSI MANUAL CM',
            0,
            NVL (
               DECODE (
                  rct.ctt_type_name,
                  'Z-Price Discount CM',
                  DECODE (
                     rctla.interface_line_attribute2,
                     'Z_Sales Return',
                     NVL (
                        sr_unit_cost.unit_cost,
                        mtt.unit_cost
                     ),
                     0
                  ),
                  'Price Discount (CM)',
                  DECODE (
                     rctla.interface_line_attribute2,
                     'Sales Return',
                     sr_unit_cost.unit_cost,
                     0
                  ),
                  'Online Channels CM',
                  DECODE (
                     rctla.interface_line_attribute2,
                     'Sales Return',
                     sr_unit_cost.unit_cost,
                     0
                  ),
                  'Z_Sales Return',
                  DECODE (
                     rctla.interface_line_attribute2,
                     'Z_Sales Return',
                     NVL (
                        sr_unit_cost.unit_cost,
                        mtt.unit_cost
                     ),
                     'Sales Return',
                     NVL (
                        sr_unit_cost.unit_cost,
                        mtt.unit_cost
                     ),
                     0
                  ),
                  'Sales Return',
                  DECODE (
                     rctla.interface_line_attribute2,
                     'Sales Return',
                     NVL (
                        sr_unit_cost.unit_cost,
                        mtt.unit_cost
                     ),
                     0
                  ),
                  'TDR Sales Return',
                  sr_unit_cost.unit_cost,
                  'Z_Price Discount(DM)',
                  0,
                  'Price Discount (DM)',
                  0,
                  'Credit Memo',
                  NVL (
                     sr_unit_cost.unit_cost,
                     mtt.unit_cost
                  ),
                  mtt.unit_cost
               ),
               0
            )
         )
      )
   END Cost_of_Goods_Sold,
   rct.invoice_currency_code CoG_Sold_Currency_Code
FROM
   XXMSICN_RA_CUSTOMER_TRX_ALL_V rct,
   ra_customer_trx_lines_all rctla,
   hz_cust_accounts sold_to_acct,
   mtl_mfg_part_numbers_all_v mmpn,
   mtl_system_items_b msib,
   mtl_item_categories_v micv,
   oe_order_headers_all ooha,
   oe_transaction_types_tl ottt,
   (
      SELECT
         A.inventory_item_id,
         A.trx_source_line_id line_id,
         NVL (A.trx_source_delivery_id, '0') delivery_id,
         DECODE (
            SUM (A.transaction_quantity),
            0,
            0,
            NVL (SUM (A.transaction_quantity * A.new_cost), 0) / SUM (A.transaction_quantity)
         ) unit_cost,
         A.costed_flag,
         A.invoiced_flag,
         A.final_completion_flag,
         b.segment1 || '-' || b.segment2 || '-' || b.segment3 || '-' || b.segment4 || '-' || b.segment5 || '-' || b.segment6 || '-' || b.segment7 || '-' || b.segment8 || '-' || b.segment9 || '-' || b.segment10 cogs_acct,
         subinventory_code
      FROM
         inv.mtl_material_transactions A,
         gl.gl_code_combinations b
      WHERE
         A.trx_source_line_id IS NOT NULL
         AND A.distribution_account_id = b.code_combination_id(+)
         AND A.subinventory_code IS NOT NULL
      GROUP BY
         A.inventory_item_id,
         A.trx_source_line_id,
         NVL (A.trx_source_delivery_id, '0'),
         A.costed_flag,
         A.invoiced_flag,
         A.final_completion_flag,
         b.segment1 || '-' || b.segment2 || '-' || b.segment3 || '-' || b.segment4 || '-' || b.segment5 || '-' || b.segment6 || '-' || b.segment7 || '-' || b.segment8 || '-' || b.segment9 || '-' || b.segment10,
         subinventory_code
   ) mtt,
   (
      SELECT
         A.inventory_item_id,
         srl.line_id,
         NVL (A.trx_source_delivery_id, '0') delivery_id,
         DECODE (
            SUM (A.transaction_quantity),
            0,
            0,
            NVL (SUM (A.transaction_quantity * A.new_cost), 0) / SUM (A.transaction_quantity)
         ) unit_cost,
         A.costed_flag,
         A.invoiced_flag,
         A.final_completion_flag,
         0 PRICE_ADJUSTMENT_ID
      FROM
         inv.mtl_material_transactions A,
         oe_order_lines_all srl,
         oe_order_lines_all orl,
         oe_order_headers_all ooha
      WHERE
         A.trx_source_line_id IS NOT NULL
         AND A.subinventory_code IS NOT NULL
         AND orl.line_id = srl.return_attribute2
         AND orl.line_id = A.trx_source_line_id
         AND A.transaction_reference = TO_CHAR (ooha.header_id)
      GROUP BY
         A.inventory_item_id,
         srl.line_id,
         NVL (A.trx_source_delivery_id, '0'),
         A.costed_flag,
         A.invoiced_flag,
         A.final_completion_flag
      UNION
      SELECT
         NULL,
         line_id,
         NULL,
         0,
         NULL,
         NULL,
         NULL,
         PRICE_ADJUSTMENT_ID
      FROM
         OE_PRICE_ADJUSTMENTS_V
   ) sr_unit_cost
WHERE
   rct.interface_header_attribute1 = TO_CHAR (ooha.order_number)
   AND ottt.transaction_type_id = ooha.order_type_id
   AND sold_to_acct.cust_account_id = ooha.sold_to_org_id
   AND rct.complete_flag = 'Y'
   AND rct.customer_trx_id = rctla.customer_trx_id
   AND rctla.line_type = 'LINE'
   AND mmpn.inventory_item_id = rctla.inventory_item_id
   AND msib.inventory_item_id = rctla.inventory_item_id
   AND msib.organization_id = ooha.ship_from_org_id
   AND micv.category_set_name = 'ITEM_CATEGORIES_MSI'
   AND micv.segment1 IN ('CNS:APC', 'ESS:APC', 'UPS:APC')
   AND mtt.subinventory_code NOT IN (
      'CLASS A/B',
      'CLASS B',
      'FINANCE',
      'WRITE OFF',
      'RTVFPU'
   )
   AND micv.segment5 <> 'OTH'
   AND msib.segment1 NOT LIKE '%-NTR-%'
   AND micv.organization_id = msib.organization_id
   AND micv.inventory_item_id = msib.inventory_item_id
   AND NVL (rctla.interface_line_attribute6, '0') = TO_CHAR (mtt.line_id(+))
   AND NVL (rctla.interface_line_attribute3, '0') = mtt.delivery_id(+)
   AND rctla.inventory_item_id = mtt.inventory_item_id(+)
   AND TO_CHAR (sr_unit_cost.line_id(+)) = NVL (rctla.interface_line_attribute6, '0')
   AND sr_unit_cost.PRICE_ADJUSTMENT_ID(+) = NVL (rctla.interface_line_attribute11, '0')
   AND TRUNC (rct.trx_date) >= TRUNC (NVL (:p_date_from, rct.trx_date))
   AND TRUNC (rct.trx_date) <= TRUNC (NVL (:p_date_to, rct.trx_date))

我需要运行这个 PL/SQL 查询,以便我可以获取我的数据集的表和列。这是我的数据集:

【问题讨论】:

  • 那么,xxmsi_erp_dev_lib_pkg.get_flex_value_desc 是 PL/SQL 包吗?如果这是用户定义的函数,您的查询本身似乎是一个普通的 SQL 查询。请edit 澄清您的问题,并删除 [windows-services] 标签,并添加 [plsql] 标签。另见minimal reproducible example

标签: c# .net sql-server oracle windows-services


【解决方案1】:

经过2天的寻找解决方案我已经解决了我的问题,众所周知,Visual Studio 2019的DataSet Designer中的DataTable在结果被拖到类后具有强类型。所以我所做的是在类型转换发生之前,我已经将表中的 Column 转换为特定的数据类型,例如 Varchar2。这是解决我的问题的方法:


    SELECT
       CAST(rct.trx_number AS VARCHAR(20)) INVOICE_NUMBER,
       CAST(rct.trx_date AS VARCHAR(20)) SOLD_DATE,
       CAST(NULL AS CHAR) REPORTING_PARTNER_BRANCH_ID,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-22
    • 2010-10-17
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    • 2023-03-06
    • 1970-01-01
    • 2021-08-26
    相关资源
    最近更新 更多