[英]SQL Query Builder in Visual Studio 2019 does not read PL/SQL
I tried to run a PL/SQL query in Visual Studio 2019's SQL Query Builder, unfortunately, it seems the SQL Query Builder in Visual Studio 2019 only read T-SQL from Microsoft SQL Server.
這是來自 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))
在找到解決方案 2 天后,我已經解決了我的問題,眾所周知,Visual Studio 2019 的 DataSet Designer 中的 DataTable 在結果被拖到 class 后具有強類型。 所以我所做的是在類型轉換發生之前,我已經將表中的 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,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.