方法:把數據導入BOM清單的方法是
drop table cux_bill_temp;
create table cux_bill_temp(
bill_sequence_id number
assembly_item_id number
organization_id number
assembly_item varchar
component_sequence_id number
component_quantity number
item_num number
operation_seq_num number
component_item_id number
component_item varchar
PLANNING_FACTOR number
component_yield_factor number
wip_supply_type number
supply_type varchar
supply_subinventory varchar
OPTIONAL number
OPTIONAL_disp varchar
MUTUALLY_EXCLUSIVE_OPTIONS number
MUTUALLY_EXCLUSIVE_O_disp varchar
attribute
row_num number)
;
delete cux_bill_temp;
另外的腳本文件為bill
options (skip=
LOAD DATA
INFILE bill
APPEND
INTO TABLE cux_bill_temp
FIELDS TERMINATED BY
(與中轉表相對應的字段列表)
登錄進入ORACLE數據庫服務器
select count(*) from cux_bill_temp;
update cux_bill_temp
set ASSEMBLY_ITEM=replace(ASSEMBLY_ITEM
COMPONENT_ITEM=replace(COMPONENT_ITEM
select assembly_item
from cux_bill_temp
group by assembly_item
having count(*)>
如果有重復的Item
delete cux_bill_temp
where row_num in (select min(row_num) from cux_bill_temp
group by assembly_item
having count(*)>
以下步驟為選做(如有重復才做
drop table cux_bill_a;
create table cux_bill_a
as
select assembly_item
component_item
component_quantity
PLANNING_FACTOR
component_yield_factor
supply_type
supply_subinventory
OPTIONAL_disp
MUTUALLY_EXCLUSIVE_O_disp
attribute
min(row_num) row_num
from cux_bill_temp
group by assembly_item
component_item
component_quantity
PLANNING_FACTOR
component_yield_factor
supply_type
supply_subinventory
OPTIONAL_disp
MUTUALLY_EXCLUSIVE_O_disp
attribute
delete cux_bill_temp;
insert into cux_bill_temp(
assembly_item
component_item
component_quantity
PLANNING_FACTOR
component_yield_factor
supply_type
supply_subinventory
OPTIONAL_disp
MUTUALLY_EXCLUSIVE_O_disp
attribute
row_num)
select assembly_item
component_item
component_quantity
PLANNING_FACTOR
component_yield_factor
supply_type
supply_subinventory
OPTIONAL_disp
MUTUALLY_EXCLUSIVE_O_disp
attribute
row_num
from cux_bill_a;
drop table cux_bill_a;
select assembly_item
from cux_bill_temp
group by assembly_item
having count(*)>
select distinct item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
)
order by item;
刪除:delete cux_bill_temp b
where not exists (select null from mtl_system_items where segment
delete cux_bill_temp a
where not exists (select null from mtl_system_items where segment
delete cux_item_temp;
insert into cux_item_temp(
segment
select distinct item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
)
;
將找到沒有ITEM的BOM數據放到另一個表中
create table cux_bom_temp
select distinct item
from (
select distinct assembly_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
union
select distinct component_item item
from cux_bill_temp b
where not exists (select null from mtl_system_items where segment
)
update cux_bill_temp b
set assembly_item_id=(select inventory_item_id from mtl_system_items
where segmen
From:http://tw.wingwit.com/Article/program/Oracle/201311/18605.html