oracle中的查询转换
如何更改给定的查询:oracle中的查询转换,oracle,oracle10g,Oracle,Oracle10g,如何更改给定的查询: 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_n
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
到
您正在尝试将旧式联接更改为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\u离散\u作业
,您正在尝试使用它的列。还有这个旧语法:
wdjC.wip_entity_id=weC.wip_entity_id(+)
应更改为左联接
,而不是内部联接
。
我想知道是否需要wip\u离散\u作业
——在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
您显然已经更改了查询。那么你的问题是什么呢?它在和wip_离散_作业wdjP内部连接wip_实体weP on wdjP上出现错误。wip_实体_ID=weP.wip_实体_ID ORA-00920:无效的关系运算符如果答案解决了问题,你应该将其标记为正确。
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