如何根据主产品编码及联产品编码,快速导入BOM中的联产品设置?(注意联产品产量一定,都是0.05,单位都是kg)
[url=][/url]
- 数据库创建一个临时表
- CREATE TABLE "PEIDA"."TEMP_A"
- ( "MAINCODE" NVARCHAR2(50), --主产品编码
- "SUBCODE" NVARCHAR2(50) --联产品编码
- )
复制代码
- PL/SQL Developer中,找到该表,右键 【编辑数据】。将主/联产品编码直接拷贝进入。提交
- 编写SQL:insert into ..... select from 模式插入数据。
- insert into bd_bom_outputs (CASTUNITID,
- CBOM_OUTPUTSID,
- CBOMID,
- CCUSTOMERID,
- CCUSTOMERID_V,
- CMATERIALID,
- CMATERIALVID,
- CPRODUCTORID,
- CPROJECTID,
- CUNITID,
- CVENDORID,
- CVENDORID_V,
- DR,
- FOUTPUTTYPE,
- NASTOUTPUTNUM,
- NBYPRODSPTNUM,
- NOUTPUTNUM,
- PK_GROUP,
- PK_ORG,
- PK_ORG_V,
- TS,
- VBDEF1,
- VBDEF10,
- VBDEF11,
- VBDEF12,
- VBDEF13,
- VBDEF14,
- VBDEF15,
- VBDEF16,
- VBDEF17,
- VBDEF18,
- VBDEF19,
- VBDEF2,
- VBDEF20,
- VBDEF3,
- VBDEF4,
- VBDEF5,
- VBDEF6,
- VBDEF7,
- VBDEF8,
- VBDEF9,
- VCHANGERATE,
- VFREE1,
- VFREE10,
- VFREE2,
- VFREE3,
- VFREE4,
- VFREE5,
- VFREE6,
- VFREE7,
- VFREE8,
- VFREE9,
- VROWNO)
- select '0001Z0100000000000XI' as CASTUNITID
- ,'0001INSERT' || LPAD(row_number() over(order by A.MAINCODE,A.Subcode),10,'0') as CBOM_OUTPUTSID
- , bom.cbomid
- , '~' as CCUSTOMERID
- , '~' as CCUSTOMERID_V
- , sm.pk_material CMATERIALID
- , sm.pk_material CMATERIALVID
- , '~' CPRODUCTORID
- , '~' CPROJECTID
- ,'0001Z0100000000000XI' CUNITID,
- '~' CVENDORID,
- '~' CVENDORID_V,
- 0 DR,
- 2 FOUTPUTTYPE,
- 0.05 NASTOUTPUTNUM,
- 0.00 NBYPRODSPTNUM,
- 0.05 NOUTPUTNUM,
- bom.pk_group PK_GROUP,
- bom.pk_org PK_ORG,
- bom.pk_org_v PK_ORG_V,
- bom.ts as ts,
- '~' VBDEF1,
- '~' VBDEF10,
- '~' VBDEF11,
- '~' VBDEF12,
- '~' VBDEF13,
- '~' VBDEF14,
- '~' VBDEF15,
- '~' VBDEF16,
- '~' VBDEF17,
- '~' VBDEF18,
- '~' VBDEF19,
- '~' VBDEF2,
- '~' VBDEF20,
- '~' VBDEF3,
- '~' VBDEF4,
- '~' VBDEF5,
- '~' VBDEF6,
- '~' VBDEF7,
- '~' VBDEF8,
- '~' VBDEF9,
- '1/1' VCHANGERATE,
- '~' VFREE1,
- '~' VFREE10,
- '~' VFREE2,
- '~' VFREE3,
- '~' VFREE4,
- '~' VFREE5,
- '~' VFREE6,
- '~' VFREE7,
- '~' VFREE8,
- '~' VFREE9,
- ROW_NUMBER()OVER(partition by A.Maincode order by A.Subcode) VROWNO
- from temp_a A
- inner join bd_material mm on A.Maincode=mm.code and mm.dr=0
- inner join bd_bom bom on bom.hcmaterialid = mm.pk_material and bom.dr=0
- inner join bd_material sm on A.Subcode = sm.code and sm.dr=0
复制代码
|