国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

在Oracle ERP中導數據(BOM清單)

2024-08-29 13:36:52
字體:
來源:轉載
供稿:網友

  方法:把數據導入BOM清單的方法是,把數據導入接口表中,讓其自動運行既可。上傳文件的時候,要注重使 用ASCII字符模式。
  
  1、自己建立一中轉表
  
  drop table cux_bill_temp;
  
  create table cux_bill_temp(
  
  bill_sequence_id number,
  
  assembly_item_id number,
  
  organization_id number,
  
  assembly_item varchar2(50), --BOM
  
  component_sequence_id number,
  
  component_quantity number, --組件數量
  
  item_num number, --項目序列
  
  Operation_seq_num number, --工序序列
  
  component_item_id number,
  
  component_item varchar2(50), --組件
  
  PLANNING_FACTOR number, --計劃%d100
  
  component_yield_factor number, --產出率d1
  
  wip_supply_type number, --供給類型
  
  supply_type varchar2(50),
  
  supply_subinventory varchar2(50), --供給子庫存
  
  OPTIONAL number, --可選的
  
  OPTIONAL_disp varchar2(10), --可選的
  
  MUTUALLY_EXCLUSIVE_OPTIONS number, --互不相容
  
  MUTUALLY_EXCLUSIVE_O_disp varchar2(10), --互不相容
  
  attribute1 varchar2(50), --排序號
  
  row_num number)
  
  ;
  
  2、刪除中轉表中的數據
  
  delete cux_bill_temp;
  
  3、把要導入的數據放在擴展名為*.csv的文件中,且要相對應于中轉表的字段,本例中的文件名為bill.csv。
  
  另外的腳本文件為bill.ctl,其內容如下:
  
  options (skip=1) //跳過第一行,一般第一行為其字段說明
  
  LOAD DATA
  
  INFILE bill.csv //bill.csv為數據文件
  
  APPEND
  
  INTO TABLE cux_bill_temp
  
  FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
  
  (與中轉表相對應的字段列表)
  
  登錄進入Oracle數據庫服務器,利用命令:(sqlload 用戶名/密碼@數據庫名)載入文件bill.csv的數據入中轉表。
  
  4、查看中轉表中的記錄數(以備導入數據后進行對比)
  
  select count(*) from cux_bill_temp;
  
  5、去除導入時在表bill.csv中的要害字段的空格字符,以免影響導入。
  
  update cux_bill_temp
  
  set ASSEMBLY_ITEM=replace(ASSEMBLY_ITEM,' ',''),
  
  COMPONENT_ITEM=replace(COMPONENT_ITEM,' ','');
  
  6、查看是否有重復的選項(既是否重復了Item)
  
  select assembly_item,component_item,min(row_num),count(*)
  
  from cux_bill_temp
  
  group by assembly_item,component_item
  
  having count(*)>1;
  
  假如有重復的Item,則要刪除(或是重新合并)
  
  delete cux_bill_temp
  
  where row_num in (select min(row_num) from cux_bill_temp
  
  group by assembly_item,component_item
  
  having count(*)>1);
  
  以下步驟為選做(如有重復才做,沒有重復不做7-10)
  
  7、再重新建立一個臨時表(對于有重復數據,則只取一條數據,現取row_num最小的一條)
  
  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,
  
  attribute1,
  
  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,
  
  attribute1;

  
  8、刪除cux_bill_temp表
  
  delete cux_bill_temp;
  
  9、再重cux_bill_a表中把數據導入給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,
  
  attribute1,
  
  row_num)
  
  select assembly_item,
  
  component_item,
  
  component_quantity,
  
  PLANNING_FACTOR,
  
  component_yield_factor,
  
  supply_type,
  
  supply_subinventory,
  
  OPTIONAL_disp,
  
  MUTUALLY_EXCLUSIVE_O_disp,
  
  attribute1,
  
  row_num
  
  from cux_bill_a;
  
  10、刪除表cux_bill_a
  
  drop table cux_bill_a;
  
  11、再檢查一次表,是否有重復的數據
  
  select assembly_item,component_item,min(row_num),count(*)
  
  from cux_bill_temp
  
  group by assembly_item,component_item
  
  having count(*)>1;
  
  12、查看在mtl_system_items表中,既是在庫存表中,有沒有不存在的Item.
  
  select distinct item
  
  from (
  
  select distinct assembly_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
  
  union
  
  select distinct component_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
  
  )
  
  order by item;
  
  13、假如在mtl_system_items中,有不存在的物品ITEM時,要把其刪除(或是把這些物品Item導入到系統中)
  
  刪除:delete cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2);
  
  delete cux_bill_temp a
  
  where not exists (select null from mtl_system_items where segment1=a.assembly_item and organization_id=2);
  
  14、對沒有物品Item的進行處理,把其放入另一臨時表cux_item_temp中(以備查詢及導入mtl_system_items表中)
  
  delete cux_item_temp;
  
  insert into cux_item_temp(
  
  segment1,description)
  
  select distinct item,item
  
  from (
  
  select distinct assembly_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
  
  union
  
  select distinct component_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
  
  )
  
  ;

  
  將找到沒有ITEM的BOM數據放到另一個表中,以備下次ITEM導入后在導BOM
  
  create table cux_bom_temp1
  
  select distinct item
  
  from (
  
  select distinct assembly_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.assembly_item and organization_id=2)
  
  union
  
  select distinct component_item item
  
  from cux_bill_temp b
  
  where not exists (select null from mtl_system_items where segment1=b.component_item and organization_id=2)
  
  )
  
  -----------------------------------------------------------------------------------------------------------
  
  15、從表mtl_system_items中把物品的編碼ID加入中轉表cux_bill_temp表(從項目主組織)中
  
  update cux_bill_temp b
  
  set assembly_item_id=(select inventory_item_id from mtl_system_items
  
  where segmen

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陵水| 隆林| 连州市| 凌海市| 黔西县| 华池县| 石门县| 息烽县| 青河县| 石阡县| 东丰县| 天台县| 惠东县| 东阿县| 离岛区| 万全县| 图木舒克市| 南乐县| 香港 | 西畴县| 盖州市| 弋阳县| 清苑县| 杭锦后旗| 武隆县| 皮山县| 石河子市| 玛多县| 洱源县| 青海省| 巧家县| 德化县| 龙江县| 合水县| 兖州市| 龙泉市| 遂昌县| 韶关市| 金秀| 靖边县| 隆化县|