C/C++教程

Teancenter BOM提取SQL脚本

本文主要是介绍Teancenter BOM提取SQL脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

--查询所有发布的QN3Part所有版本
create table QN3PARTREVISION_REV as
select pir.puid ,pi.pitem_id,pir.pitem_revision_id,pqn3ir.pqn3_cl_id,pqn3ir.pqn3_cz,pqn3ir.pqn3_clgg1,pqn3ir.pqn3_clgg,pqn3ir.pqn3_clgg3,pqn3ir.pqn3_zl,
pqn3ir.pqn3_tzjdbs_s,pqn3ir.pqn3_tzjdbs_b,pqn3ir.pqn3_tzjdbs_a,pqn3ir.pqn3_tydh,pws.pqn3_doc_type1,pws.pqn3_doc_type2,pqn3ir.pqn3_lsdh,
pqn3ir.pqn3_zldj,pqn3ir.pqn3_tf,pqn3ir.pqn3_sfct,pqn3ir.pqn3_gztx,pqn3ir.pqn3_is_tyj,pqn3ir.pqn3_is_jp,pqn3ir.pqn3_is_ysj,pqn3ir.pqn3_ywmc,
pqn3ir.pqn3_is_daj,pws.pip_classification,pqn3ir.pqn3_csxmh,pir.pqn3_ggdbh,'AAAAAAAAAAAAAAA' QN3_RELECN,'AAAAAAAAAAAAAAA' QN3_RELDOC ,
plt.pname RELEASE_STATUSES ,pqn3ir.pqn3_cpxh

from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pqn3partrevision pqn3ir,
INFODBA.ppom_application_object ppa,
--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1

and pws.pobject_type='QN3PartRevision'
and pqn3ir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;


create index QN3PARTREVISION_REV_0 on QN3PARTREVISION_REV(puid,pitem_id,pitem_revision_id,RELEASE_STATUSES);

 

--查询QN3Part最新版本的数据
select rev.puid from QN3PARTREVISION_REV rev

( select pitem_id,max(pitem_Revision_id) rev_id from QN3PARTREVISION_REV group by pitem_id) aa
where rev.pitem_id=aa.pitem_id
and rev.pitem_revision_id=aa.rev_id;

 

--查所有的QN3Part BOM中的子件
drop table zyq_bom;
create table zyq_bom as
select p.pitem_id ppitem_id,
pr.pitem_revision_id ppitem_revision_id,
cp.pitem_id cpitem_id,
cpr.pitem_revision_id cpitem_revision_id,
sum(abs(pps.pqty_value)) qnantity
,pps.pqn3_fsj
,pps.pqn3_config_priority
,pps.pqn3_config_linkage
,pps.pqn3_config_base
,pps.pqn3_hanliang
from infodba.pitem p,
infodba.pitem cp,
infodba.pitemrevision pr,
infodba.pitemrevision cpr,
infodba.ppsoccurrence pps,
infodba.ppsbomviewrevision ppsb,
infodba.pstructure_revisions ps
where --p.pitem_id = '00630891810000000' and --填写父级ID

--
p.puid = pr.ritems_tagu
--and pr.pitem_revision_id = 'F' --填写父级版本号
and pr.puid in( --取最大版本
select rev.puid from QN3PARTREVISION_REV rev,
( select pitem_id,max(pitem_Revision_id) rev_id from QN3PARTREVISION_REV group by pitem_id) aa
where rev.pitem_id=aa.pitem_id
and rev.pitem_revision_id=aa.rev_id
and p.pitem_id=rev.pitem_id
)

and pr.puid = ps.puid
and ps.pvalu_0 = ppsb.puid
and pps.rparent_bvru = ppsb.puid
and pps.rchild_itemu = cp.puid
and cp.puid = cpr.ritems_tagu
and cpr.pitem_revision_id =
(select pitem_revision_id
from (select pr.ritems_tagu,pr.pitem_revision_id
from infodba.pitemrevision pr,
infodba.pworkspaceobject po
where pr.puid = po.puid
--and po.pdate_released is not null --已发布
and po.pactive_seq <> 0
order by pr.ritems_tagu,length(pr.pitem_revision_id) desc,

pr.pitem_revision_id desc) a
where rownum = 1
and a.ritems_tagu = cpr.ritems_tagu)
group by p.pitem_id, cp.pitem_id, cpr.pitem_revision_id,pps.pqn3_fsj,pr.pitem_revision_id
,pps.pqn3_config_priority
,pps.pqn3_config_linkage
,pps.pqn3_config_base
,pps.pqn3_hanliang
order by cp.pitem_id;

 

 

create index zyq_bom_0 on zyq_bom(ppitem_id,ppitem_revision_id,cpitem_id,cpitem_revision_id,qnantity)

--
--查询所有的已发布的最新的采购件

create table QN3COMMPARTREVISION_REV as
select pir.puid ,pi.pitem_id,pir.pitem_revision_id,
pqn3ir.pqn3_zl,pqn3ir.pqn3_SFBZJ,pqn3ir.pqn3_bzdh,pqn3ir.pqn3_ZLDJ,
pqn3ir.pqn3_CZ,pqn3ir.pqn3_CLGG,pqn3ir.pqn3_CLGG1,pqn3ir.pqn3_CLGG3,
pqn3ir.pqn3_BMCLFS,pqn3ir.pqn3_LSBM,pqn3ir.pqn3_SFZGPT,pqn3ir.pqn3_SFDAJ,pqn3ir.pqn3_BSQB,pqn3ir.pqn3_TDSM,
pqn3ir.pqn3_GYS,pqn3ir.pqn3_CGLX,pqn3ir.pqn3_ZT,pqn3ir.pqn3_XL,pqn3ir.pqn3_WGZL,pqn3ir.pqn3_DWZL,pqn3ir.pqn3_YWMC,
pqn3ir.pqn3_TZH,pqn3ir.pqn3_ZLHY,'AAAAAAAAAAAAAAA' PQN3_ECN,pqn3ir.PQN3_UNIQUE,
pws.pqn3_doc_type1,pws.pqn3_doc_type2,
plt.pname RELEASE_STATUSES

from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pqn3commpartrevision pqn3ir,
INFODBA.ppom_application_object ppa,
--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
and pws.pobject_type='QN3CommPartRevision'
and pqn3ir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index QN3COMMPARTREVISION_REV_0 on QN3COMMPARTREVISION_REV(puid,pitem_id,pitem_revision_id);

 

--查询所有的已发布的原材料

select * from infodba.pqn3materialrevision
drop table QN3MATERIALREVISION_REV;

create table QN3MATERIALREVISION_REV as
select pir.puid ,pi.pitem_id,pir.pitem_revision_id,
pqn3ir.pqn3_zl,pqn3ir.pqn3_CLLB,pqn3ir.pqn3_CGLX,pqn3ir.pqn3_BZDH,
pqn3ir.pqn3_CLPH,pqn3ir.pqn3_BMCLFS,pqn3ir.pqn3_CLMD,pqn3ir.pqn3_YS,
pqn3ir.pqn3_CLGG1,pqn3ir.pqn3_CLGG3,pqn3ir.pqn3_XL,pqn3ir.pqn3_ZLHY,pqn3ir.pqn3_CZID,pqn3ir.pqn3_SFXHJ,
pqn3ir.pqn3_WGZL,pqn3ir.pqn3_TDSM,pqn3ir.pqn3_CZ,pqn3ir.pqn3_CLGG,'AAAAAAAAAAAAAAA' PQN3_ECN,pqn3ir.PQN3_UNIQUE,
pws.pqn3_doc_type1,pws.pqn3_doc_type2,
plt.pname RELEASE_STATUSES

from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pqn3materialrevision pqn3ir,
INFODBA.ppom_application_object ppa,
--发布状态

infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
and pws.pobject_type='QN3MaterialRevision'
and pqn3ir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index QN3MATERIALREVISION_REV_0 on QN3MATERIALREVISION_REV(puid,pitem_id,pitem_revision_id);

select count(*) from QN3MATERIALREVISION_REV;

--查询所有的已发布的辅料
select * from infodba.pqn3flrevision
drop table QN3FLREVISION_REV;

create table QN3FLREVISION_REV as
select pir.puid ,pi.pitem_id,pir.pitem_revision_id,
pqn3ir.pqn3_zl,pqn3ir.pqn3_CLLB,pqn3ir.pqn3_CGLX,pqn3ir.pqn3_BZDH,
pqn3ir.pqn3_CLPH,pqn3ir.PQN3_CLGG,pqn3ir.pqn3_BMCLFS,pqn3ir.pqn3_YS
,pqn3ir.pqn3_XL,pqn3ir.pqn3_ZLHY,pqn3ir.pqn3_CZID,pqn3ir.pqn3_SFXHJ,
pqn3ir.pqn3_WGZL,pqn3ir.pqn3_TDSM,pqn3ir.pqn3_CZ,'AAAAAAAAAAAAAAA' PQN3_ECN,pqn3ir.PQN3_UNIQUE,
pws.pqn3_doc_type1,pws.pqn3_doc_type2,
plt.pname RELEASE_STATUSES
from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pqn3flrevision pqn3ir,
INFODBA.ppom_application_object ppa,
--发布状态

infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
and pws.pobject_type='QN3FLRevision'
and pqn3ir.puid=pir.puid
and pir.puid=pws.puid
and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid
and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index QN3FLREVISION_REV_0 on QN3FLREVISION_REV(puid,pitem_id,pitem_revision_id);

select * from QN3FLREVISION_REV;

 

--查询所有的itemrevision 组只取了最底层的组,无意义
drop table ITEM_REV;

create table ITEM_REV as
(select u.puser_id,u.puser_name,g.pname,aa.*,uom.psymbol from( select pir.puid ,pi.pitem_id,pir.pitem_revision_id,pi.ruom_tagu,
pws.pobject_name,pws.pobject_desc,
pws.pobject_type,
pws.pqn3_doc_type1,pws.pqn3_doc_type2,
plt.pname RELEASE_STATUSES ,
ppa.rowning_groupu,
ppa.rowning_useru
from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
INFODBA.ppom_application_object ppa,
--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
--and pws.pobject_type='QN3FLRevision'
--and pqn3ir.puid=pir.puid
and pir.puid=pws.puid
and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid
and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu ) aa

left join infodba.punitofmeasure uom
on aa.ruom_tagu=uom.puid

inner join infodba.ppom_user u on u.puid=aa.rowning_useru
inner join infodba.ppom_group g on g.puid=aa.rowning_groupu
);
create index ITEM_REV_0 on ITEM_REV(puid,pitem_id,pitem_revision_id,puser_id,RELEASE_STATUSES,psymbol);

 

--查询所有发布的总工艺版本

create table GY9MainProcessRevision as

select pir.puid ,pi.pitem_id,pir.pitem_revision_id,
pgy9mir.pgy9_roughpieces_weight,pgy9mir.pgy9_part_type,pgy9mir.pgy9_material_num,pgy9mir.pgy9_material_shap,pgy9mir.pgy9_material_size,
pgy9mir.pgy9_material_dimension,pgy9mir.pgy9_machining_allowance,pgy9mir.pgy9_qiedao_quantity,pgy9mir.pgy9_clamping_length,pgy9mir.pgy9_cutting_quantity,
pgy9mir.pgy9_process_type,pgy9mir.pgy9_plant,pgy9mir.pgy9_cutting_last_mod_user,pgy9mir.pgy9_material_id,
plt.pname RELEASE_STATUSES
from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pgy9mainprocessrevision pgy9mir,
INFODBA.ppom_application_object ppa,
--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
--and pws.pobject_type='QN3PartRevision'
and pgy9mir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index GY9MainProcessRevision_0 on GY9MainProcessRevision(puid,pitem_id,Pitem_Revision_Id,Pgy9_Plant);

 

--所有的发布的专业工艺
select * from infodba.pworkspaceobject pws where pws.pobject_type like 'GY9Pro%Revision';

select * from infodba.pgy9subprocessrevision

create table GY9SubProcessRevision as

select pir.puid ,pi.pitem_id GY9_SUBPROCESS_ITEM_ID,
substr(pi.pitem_id,0,length(pi.pitem_id) -8) QN3_PART_ITEM_ID,
substr(pi.pitem_id,0,length(pi.pitem_id) -1) GY9_MAINPROCESS_ITEM_ID ,
substr(pi.pitem_id,length(pi.pitem_id) -6,4) plant_id,
pir.pitem_revision_id,pgy9subir.pgy9_responsibi_unit,
plt.pname RELEASE_STATUSES ,
pws.pobject_type
from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pgy9subprocessrevision pgy9subir,
INFODBA.ppom_application_object ppa,
--发布状态

--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
--and pws.pobject_type='QN3PartRevision'
and pgy9subir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index GY9SubProcessRevision_0 on GY9SubProcessRevision(puid,QN3_PART_ITEM_ID,GY9_SUBPROCESS_ITEM_ID,GY9_MAINPROCESS_ITEM_ID,plant_id);

select * from GY9SubProcessRevision where GY9_SUBPROCESS_ITEM_ID='00630890002020000S-2001-01';

--所有的发布的工序

select * from infodba.pmeoprevision;

create table PGY9OPREVISION as

select pir.puid ,pi.pitem_id,pir.pitem_revision_id,
pmeopir.pgy9_remark,pmeopir.pgy9_op_time_symbol,pmeopir.pgy9_op_unit,pmeopir.pgy9_op_type,
pmeopir.pgy9_op_temp_external,pmeopir.pgy9_op_requirement,pmeopir.pgy9_op_quota,pmeopir.pgy9_op_process_time1,
pmeopir.pgy9_op_process_time,pmeopir.pgy9_op_person_count,pmeopir.pgy9_op_method,pmeopir.pgy9_op_is_external,pmeopir.pgy9_op_is_crux,
pmeopir.pgy9_op_fix_external,pmeopir.pgy9_op_external_name,pmeopir.pgy9_op_external_id,pmeopir.pgy9_op_content
,pmeopir.pgy9_op_contain_material,pmeopir.pgy9_control_code,
plt.pname RELEASE_STATUSES ,
pws.pobject_type
from
infodba.pitem pi,
infodba.pitemrevision pir ,
INFODBA.pworkspaceobject pws,
infodba.pmeoprevision pmeopir,
INFODBA.ppom_application_object ppa,

--发布状态
infodba.prelease_status_list psl,
infodba.preleasestatus plt
where pws.pactive_seq !=0
and pws.vla_751_18 =1
--and pws.pobject_type='QN3PartRevision'
and pmeopir.puid=pir.puid
and pir.puid=pws.puid

and pir.puid = psl.puid
and psl.pvalu_0 = plt.puid

and ppa.puid=pws.puid
and pi.puid=pir.ritems_tagu;

create index PGY9OPREVISION_0 on PGY9OPREVISION(puid,pitem_id,pitem_revision_id);

select * from PGY9OPREVISION where PGY9OPREVISION='00630890002020000S-2001-01';

 

--查所有的工艺的BOM 总工艺-专业工艺-工序-工艺资源
drop table zyq_gybom;


create table zyq_gybom as

select bb.*,ppst.pname from (
select p.pitem_id ppitem_id,
pr.pitem_revision_id ppitem_revision_id,
cp.pitem_id cpitem_id,
cpr.pitem_revision_id cpitem_revision_id,
sum(abs(pps.pqty_value)) qnantity
,pps.pqn3_fsj
,pps.pqn3_config_priority
,pps.pqn3_config_linkage
,pps.pqn3_config_base
,pps.pqn3_hanliang
,pps.rocc_typeu
from infodba.pitem p,
infodba.pitem cp,
infodba.pitemrevision pr,
infodba.pitemrevision cpr,
infodba.ppsoccurrence pps,
infodba.ppsbomviewrevision ppsb,
infodba.pstructure_revisions ps
where --p.pitem_id = '00630891810000000' and --填写父级ID

--
p.puid = pr.ritems_tagu
--and pr.pitem_revision_id = 'F' --填写父级版本号
and pr.puid in( --取最大版本
select rev.puid from GY9MainProcessRevision rev, --总工艺
(
select pitem_id,max(pitem_Revision_id) rev_id from GY9MainProcessRevision group by pitem_id
) aa
where rev.pitem_id=aa.pitem_id
and rev.pitem_revision_id=aa.rev_id
and p.pitem_id=rev.pitem_id
union
select rev1.puid from GY9SubProcessRevision rev1,--专业工艺
(
select GY9_SUBPROCESS_ITEM_ID pitem_id,max(pitem_Revision_id) rev_id from GY9SubProcessRevision group by GY9_SUBPROCESS_ITEM_ID
) aa
where rev1.pitem_revision_id=aa.rev_id
and rev1.gy9_subprocess_item_id=aa.pitem_id
and p.pitem_id=rev1.GY9_SUBPROCESS_ITEM_ID

union
select rev.puid from PGY9OPREVISION rev,--工序

(
select pitem_id,max(pitem_Revision_id) rev_id from PGY9OPREVISION group by pitem_id
) aa
where rev.pitem_id=aa.pitem_id
and rev.pitem_revision_id=aa.rev_id
and p.pitem_id=rev.pitem_id
)

and pr.puid = ps.puid
and ps.pvalu_0 = ppsb.puid
and pps.rparent_bvru = ppsb.puid
and pps.rchild_itemu = cp.puid
and cp.puid = cpr.ritems_tagu
and cpr.pitem_revision_id =
(select pitem_revision_id
from (select pr.ritems_tagu,pr.pitem_revision_id
from infodba.pitemrevision pr,
infodba.pworkspaceobject po
where pr.puid = po.puid
--and po.pdate_released is not null --已发布

and po.pactive_seq <> 0
order by pr.ritems_tagu,length(pr.pitem_revision_id) desc,
pr.pitem_revision_id desc) a
where rownum = 1
and a.ritems_tagu = cpr.ritems_tagu)
group by p.pitem_id, cp.pitem_id, cpr.pitem_revision_id,pps.pqn3_fsj,pr.pitem_revision_id
,pps.pqn3_config_priority
,pps.pqn3_config_linkage
,pps.pqn3_config_base
,pps.pqn3_hanliang
,pps.rocc_typeu
order by cp.pitem_id) bb
left join infodba.ppsoccurrencetype ppst on bb.rocc_typeu=ppst.puid;


create index zyq_gybom_0 on zyq_gybom(ppitem_id,ppitem_revision_id,cpitem_id,cpitem_revision_id,qnantity)


select * from zyq_gybom where pname='MEOther'

select gy9m.ppitem_id,gy9m.ppitem_revision_id,p.ppitem_id,p.ppitem_revision_id,op.*from
zyq_gybom p
inner join zyq_gybom op on op.ppitem_id=p.cpitem_id
inner join zyq_gybom gy9m on p.ppitem_id=gy9m.cpitem_id
where gy9m.ppitem_id='00630890002020000S-2001-0'
and op.cpitem_id like '0%'
where op.ppitem_id='1119648'
and op.ppitem_id like '00631140003050000';

p.ppitem_id='00630890002020000S-2001-0';

 

这篇关于Teancenter BOM提取SQL脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!