如何更改给定的查询:
select
msi.attribute1 ref_no,
msi.description,
wdj.attribute10 order_id,
wdj.net_quantity,
'' Rec_date,
'' Qty,
'' packing_dated,
trunc(sysdate) issue_date,
hca.ACCOUNT_NUMBER||'-'||ooha.cust_po_number order_no,
ooha.order_number sale_order_no,
mci.attribute5 etching,
we.wip_entity_name,
weC.wip_entity_name "Relevant ASM job"
from wip_discrete_jobs wdj,
wip_entities we,
oe_order_headers_all ooha,
oe_order_lines_all oola,
mtl_customer_items mci,
mtl_system_items_b msi,
fnd_flex_values_vl ffvv,
hz_cust_accounts hca,
wip_discrete_jobs wdjC,
wip_entities weC
where
wdj.wip_entity_id = we.wip_entity_id
and ooha.header_id=wdj.attribute10
and ooha.header_id=oola.header_id
and oola.line_id=wdj.attribute9
and oola.ordered_item_id=mci.customer_item_id
and wdj.primary_item_id=msi.inventory_item_id
and msi.segment2 = ffvv.FLEX_VALUE
and mci.customer_id=hca.cust_account_id
AND wdjC.wip_entity_id = weC.wip_entity_id(+)
AND wdjC.attribute1(+) = we.wip_entity_name
and wdj.organization_id = msi.organization_id
and ffvv.FLEX_VALUE_SET_ID = '1014875'
and wdj.attribute10 = :order_id
到
select
msi.attribute1 ref_no,
msi.description,
wdj.attribute10 order_id,
wdj.net_quantity,
'' Rec_date,
'' Qty,
'' packing_dated,
trunc(sysdate) issue_date,
hca.ACCOUNT_NUMBER||'-'||ooha.cust_po_number order_no,
ooha.order_number sale_order_no,
mci.attribute5 etching,
we.wip_entity_name
from wip_discrete_jobs wdj
join wip_entities we on wdj.wip_entity_id = we.wip_entity_id
join oe_order_headers_all ooha on ooha.header_id=wdj.attribute10
join oe_order_lines_all oola on ooha.header_id=oola.header_id and oola.line_id=wdj.attribute9
join mtl_customer_items mci on oola.ordered_item_id=mci.customer_item_id
join mtl_system_items_b msi on wdj.primary_item_id=msi.inventory_item_id
join fnd_flex_values_vl ffvv on msi.segment2 = ffvv.FLEX_VALUE
join hz_cust_accounts hca on mci.customer_id=hca.cust_account_id
and wip_discrete_jobs wdjP inner join wip_entities weP on wdjP.WIP_ENTITY_ID=weP.WIP_ENTITY_ID
and wdj.organization_id = msi.organization_id
and ffvv.FLEX_VALUE_SET_ID = '1014875'
and wdj.attribute10 = :order_id
答案 0 :(得分:1)
您正尝试将旧样式联接更改为ANSI联接,但这部分查询不正确:
...
join hz_cust_accounts hca on mci.customer_id=hca.cust_account_id
and wip_discrete_jobs wdjP
inner join wip_entities weP on wdjP.WIP_ENTITY_ID=weP.WIP_ENTITY_ID
and wdj.organization_id = msi.organization_id ...
您没有加入表wip_discrete_jobs
,而您正试图使用它的列。这个旧语法也是:
wdjC.wip_entity_id = weC.wip_entity_id(+)
应更改为left join
,而不是inner join
。
我想知道是否需要wip_discrete_jobs
- select
子句中没有此表中的列?
这是查询,首先应该与您的相同,但请仔细测试 因为没有你的结构和数据访问我没有机会验证它:
select msi.attribute1 ref_no, msi.description, wdj.attribute10 order_id,
wdj.net_quantity, '' Rec_date, '' Qty, '' packing_dated,
trunc(sysdate) issue_date,
hca.ACCOUNT_NUMBER||'-'||ooha.cust_po_number order_no,
ooha.order_number sale_order_no, mci.attribute5 etching,
we.wip_entity_name, weC.wip_entity_name "Relevant ASM job"
from wip_discrete_jobs wdj
join wip_entities we on wdj.wip_entity_id = we.wip_entity_id
join oe_order_headers_all ooha on ooha.header_id = wdj.attribute10
join oe_order_lines_all oola on ooha.header_id = oola.header_id
and oola.line_id = wdj.attribute9
join mtl_customer_items mci on oola.ordered_item_id = mci.customer_item_id
join mtl_system_items_b msi on wdj.primary_item_id = msi.inventory_item_id
and wdj.organization_id = msi.organization_id
join fnd_flex_values_vl ffvv on msi.segment2 = ffvv.FLEX_VALUE
and ffvv.FLEX_VALUE_SET_ID = '1014875'
join hz_cust_accounts hca on mci.customer_id = hca.cust_account_id
left join wip_discrete_jobs wdjC on wdjC.attribute1 = we.wip_entity_name
left join wip_entities weC on wdjC.wip_entity_id = weC.wip_entity_id
where
wdj.attribute10 = :order_id