方法:把数据导入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 segment1=b.assembly_item and organization_id=2),

component_item_id=(select inventory_item_id from mtl_system_items

where segment1=b.component_item and organization_id=2);

16、查看是否有没有物品ID的编码存在(既没有物品的ID被导入临时表cux_bill_temp中)

select row_num

from cux_bill_temp

where assembly_item_id is null or component_item_id is null;

17、对其中导入的数据进行处理

update cux_bill_temp

set OPTIONAL=1

where upper(OPTIONAL_disp) like 'Y%';

update cux_bill_temp

set OPTIONAL=2

where OPTIONAL is null;

update cux_bill_temp

set MUTUALLY_EXCLUSIVE_OPTIONS=1

where upper(MUTUALLY_EXCLUSIVE_O_DISP) like 'Y%';

update cux_bill_temp

set MUTUALLY_EXCLUSIVE_OPTIONS=2

where MUTUALLY_EXCLUSIVE_O_DISP is null;

18、查看cux_bill_temp中的数据处理是否有漏

select count(*)

from cux_bill_temp

where OPTIONAL is null

or MUTUALLY_EXCLUSIVE_OPTIONS is null

or assembly_item_id is null

or component_item_id is null;

19、更新其内的WIP_SUPPLY_TYPE;

update cux_bill_temp

set WIP_SUPPLY_TYPE=6

where component_item like 'B%';

20、删除表中的包(cux_bill_temp中),其相对应于表bom_bill_of_materials(既在表中已经存在了些选项包,不必导入包头,只需导入包内容既可)

delete cux_bill_temp t

where exists (select null from bom_bill_of_materials where assembly_item_id=t.assembly_item_id and organization_id=2);

21、利用已经写好的包写入数据(既写入接口表bom_bill_of_mtls_interface)

exec cux_bom_temp.insert_bill_15(1);

select count(*) from cux_bill_temp temp

where exits (select null from bom_inventory_components  b

where temp.bill_sequence_id=b.bill_sequence_id

and temp.component_item_id=b.component_item_id);

delete cux_bill_temp temp

where exists (select null from bom_inventory_components  b

where b.bill_sequence_id=temp.bill_sequence_id

and b.component_item_id=temp.component_item_id);

exec cux_bom_temp.insert_bill_10(1);

22、对写入的数据在接口表中的情况进行查看

select count(*) from bom_bill_of_mtls_interface;

23、接着更新

exec cux_bom_temp.insert_bill_15(1);

select count(*) from cux_bill_temp where bill_sequence_id is null;

exec cux_bom_temp.insert_bill_20(1);

去提交请求

select count(*) from bom_inventory_comps_interface;

(导入成功后)对组件进行排序

exec cux_bom_temp.update_bill_item_num4;

select count(*) from bom_inventory_comps_interface;

24、对于接口表中的数据进行导入

delete bom_bill_of_mtls_interface;

insert into bom_bill_of_mtls_interface(

assembly_type,assembly_item_id,

organization_id,

process_flag,transaction_type)

select  distinct 1,assembly_item_id,

1,

1,'CREATE'

from cux_bill_temp;

【责编:landss】

--------------------next---------------------

oracle导出BOM文件,ORACLE ERP导数据(BOM清单)-备份恢复-Oracle频道-中国IT实验室相关推荐

  1. oracle导出dmp文件教程

    oracle导出dmp文件教程 启动&关闭oracle教程 医院内网服务器导出dmp文件只要进行下面1.2.4的操作 1.切换到oralce用户 su oracle 2.使环境变量生效 sou ...

  2. toad for oracle导出dmp文件

    toad for oracle导出dmp文件 步骤: 1.选择菜单Database-->Export-->Export Utility Wizard: 2.选择Export tables, ...

  3. PLSQL Developer备份恢复oracle数据

    PLSQL Developer备份恢复oracle数据 使用PL sql提供的功能可以快速的备份恢复oracle数据. 1  导出存储过程,触发器,序列等所有用户对象.(备份) 在PL/SQL Dev ...

  4. 第四章 文件的基本管理和XFS文件系统备份恢复 随堂笔记

    第四章 文件的基本管理和XFS文件系统备份恢复 本节所讲内容: 4.1 Linux系统目录结构和相对/绝对路径. 4.2 创建/复制/删除文件,rm -rf / 意外事故 4.3 查看文件内容的命令 ...

  5. oracle导出脚本文件怎么打开,Windows下的Oracle导出脚本 -电脑资料

    Windows下的Oracle导出脚本 导出脚本内容: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...

  6. oracle 导出dmp 文件 闪退 plsql

    oracle数据库没有安装在本地,使用plsql连接操作,无法导出dmp文件, 配置ORACLE_HOME环境变量 D:\app\weizhicheng\product\11.2.0\client_1 ...

  7. 关于Oracle导出.db文件

    最简单的Oracle导出.db数据库文件 一.需要使用到的工具 1.PLSQLDev(建议使用13以上版本)2.Navicat (能支持连接SQLlite数据库)3.WPS/Office(修改文件使用 ...

  8. oracle导出dmp文件

    使用dmp方式导出时有些表未导出 原因:表创建完未执行过 1.在plsql中执行下面sql语句,将查询出的结果复制出来依次执行. select 'alter table '|| table_name ...

  9. Oracle bigfile 大文件表空间会影响rman等备份效率

    Database 是由一个或多个被称为表空间(tablespace)的逻辑存储单位构成.表空间内的逻辑存储单位为段(segment),段又可以继续划分为数据扩展(extent).而数据扩展是由一组连续 ...

最新文章

  1. 南昌计算机专业好的专科,2021年南昌计算机专业学校好不好
  2. Linux那些事儿 之 戏说USB(4)最终奥义
  3. 巨杉数据库:金融级数据库是怎样炼成的
  4. 学习3dmax的第二天
  5. 鹏博士和阿里云数据库产品达成战略合作,共赢企业数智化创新市场
  6. Spark RDD中cache和persist的区别
  7. require(),include(),require_once()和include_once()区别
  8. c#中使用消息循环机制发送接收字符串的方法和数据类型转换
  9. 数据可视化【九】单向数据流交互
  10. Python 内置模块之 ConfigParser - 解析 ini 文件
  11. Power BI Embedded 开发国内版-21V-版本实测
  12. 我的程序员之路(4)——工作半年
  13. php学到什么程度可以学thinkphp,thinkphp学习一
  14. 计算机系统-电路设计06-振荡器的内部电路实现
  15. 结构型设计模式 (1)—— 适配器模式(Adapter Pattern)
  16. matlab 字符查找函数,matlab字符函数
  17. m.微博各种接口分析
  18. 六祎-简单的排版表(python)
  19. 安装bzz1.0教程
  20. 20145306 信息安全系统设计基础 第五周博客总结

热门文章

  1. linux c之memcpy拷贝结构体到结构体、拷贝字符数组到结构体
  2. linux c之用fwrite和fread实现文件的复制
  3. 年月跨度_建筑结构丨国内跨度最大的张弦桁架工程——合肥滨湖国际会展中心二期首榀桁架滑移成功...
  4. 吵架后女生和男生的夜晚!所有男生都这样吗?
  5. office 高效办公智慧树_干货高效实用的office办公小技巧之word篇
  6. python提供什么机制处理程序运行错误_浅谈Python异常处理机制
  7. confluencejira集成_Jira Service Desk使用教程之如何将Jira Cloud与Confluence集成?
  8. linux 信号_Linux中的信号处理机制 [四]
  9. 摄像头预览左右翻转_轻薄翻转触控本里的高性能机型:惠普ENVY x360 13评测
  10. java集合框架的结构_集合框架(Collections Framework)详解及代码示例