您的位置:首页 > 其它

自己写的渠道资源导入过程

2016-01-20 08:58 190 查看
create or replace procedure PROC_YX_M_QDZY_IMPORT2 (mess out varchar2)

is

/*1.清空导入表

truncate table t_yx_qdzy_main_impl;

truncate table t_yx_qdzy_dx_impl;

truncate table t_yx_qdzy_hb_impl;

truncate table t_yx_qdzy_spj_impl;

truncate table t_yx_qdzy_dzxk_impl;

truncate table t_yx_qdzy_qg_impl;

truncate table t_yx_qdzy_bg_impl;

truncate table t_yx_qdzy_zjg_impl;

truncate table t_yx_qdzy_dg_impl;

truncate table t_yx_qdzy_mng_impl;

truncate table t_yx_qdzy_zsb_impl;

2.把数据导入t_yx_qdzy_*_impl表。*/

code varchar2(100);

sqlerr varchar2(500);

v_cnt_dx1 number;

v_cnt_dx2 number;

v_cnt_hb1 number;

v_cnt_hb2 number;

v_cnt_spj1 number;

v_cnt_spj2 number;

v_cnt_dzxk1 number;

v_cnt_dzxk2 number;

v_cnt_qg1 number;

v_cnt_qg2 number;

v_cnt_bg1 number;

v_cnt_bg2 number;

v_cnt_zjg1 number;

v_cnt_zjg2 number;

v_cnt_dg1 number;

v_cnt_dg2 number;

v_cnt_mng1 number;

v_cnt_mng2 number;

v_cnt_zsb1 number;

v_cnt_zsb2 number;

v_dx number;

v_hb number;

v_spj number;

v_dzxk number;

v_qg number;

v_bg number;

v_zjg number;

v_dg number;

v_mng number;

v_zsb number;

v_dx_id char(10);

v_hb_id char(10);

v_spj_id char(10);

v_dzxk_id char(10);

v_qg_id char(10);

v_bg_id char(10);

v_zjg_id char(10);

v_dg_id char(10);

v_mng_id char(10);

v_zsb_id char(10);

v_custcd varchar2(9);

v_max_id1 char(13);

v_max_id2 char(13);

v_cnt number;

--定义游标

--查出所有导入门店编号

cursor c_custcd is

select t.custcd from t_yx_qdzy_main_impl t;

r_custcd c_custcd%rowtype;

---------------------------------------------------

--查出所有导入灯箱门店号

cursor c_dx_custcd is

select distinct t.custcd from t_yx_qdzy_dx_impl t;

r_dx_custcd c_dx_custcd%rowtype;

----查出所有导入海报门店号

cursor c_hb_custcd is

select distinct t.custcd from t_yx_qdzy_hb_impl t;

r_hb_custcd c_hb_custcd%rowtype;

----查出所有导入视频机门店号

cursor c_spj_custcd is

select distinct t.custcd from t_yx_qdzy_spj_impl t;

r_spj_custcd c_spj_custcd%rowtype;

----查出所有导入电子相框门店号

cursor c_dzxk_custcd is

select distinct t.custcd from t_yx_qdzy_dzxk_impl t;

r_dzxk_custcd c_dzxk_custcd%rowtype;

----查出所有导入前柜门店号

cursor c_qg_custcd is

select distinct t.custcd from t_yx_qdzy_qg_impl t;

r_qg_custcd c_qg_custcd%rowtype;

----查出所有导入背柜门店号

cursor c_bg_custcd is

select distinct t.custcd from t_yx_qdzy_bg_impl t;

r_bg_custcd c_bg_custcd%rowtype;

----查出所有导入展示板门店号

cursor c_zjg_custcd is

select distinct t.custcd from t_yx_qdzy_zjg_impl t;

r_zjg_custcd c_zjg_custcd%rowtype;

----查出所有导入吊柜门店号

cursor c_dg_custcd is

select distinct t.custcd from t_yx_qdzy_dg_impl t;

r_dg_custcd c_dg_custcd%rowtype;

----查出所有导入迷你柜门店号

cursor c_mng_custcd is

select distinct t.custcd from t_yx_qdzy_mng_impl t;

r_hb_custcd c_mng_custcd%rowtype;

--查出所有导入展示板门店号

cursor c_zsb_custcd is

select distinct t.custcd from t_yx_qdzy_zsb_impl t;

r_zsb_custcd c_zsb_custcd%rowtype;

----------------------------------------------------

--查出所有导入灯箱编号

cursor c_dx_id is

select t.dx_id from t_yx_qdzy_dx_impl t;

r_dx_id c_dx_id%rowtype;

----查出所有导入海报编号

cursor c_hb_id is

select t.hb_id from t_yx_qdzy_hb_impl t;

r_hb_id c_hb_id%rowtype;

----查出所有导入视频机编号

cursor c_spj_id is

select t.spj_id from t_yx_qdzy_spj_impl t;

r_spj_id c_spj_id%rowtype;

----查出所有导入电子相框编号

cursor c_dzxk_id is

select t.dzxk_id from t_yx_qdzy_dzxk_impl t;

r_dzxk_id c_dzxk_id%rowtype;

----查出所有导入前柜编号

cursor c_qg_id is

select t.qg_id from t_yx_qdzy_qg_impl t;

r_qg_id c_qg_id%rowtype;

----查出所有导入背柜编号

cursor c_bg_id is

select t.bg_id from t_yx_qdzy_bg_impl t;

r_bg_id c_bg_id%rowtype;

----查出所有导入展示板编号

cursor c_zjg_id is

select t.zjg_id from t_yx_qdzy_zjg_impl t;

r_zjg_id c_zjg_id%rowtype;

----查出所有导入吊柜编号

cursor c_dg_id is

select t.dg_id from t_yx_qdzy_dg_impl t;

r_dg_id c_dg_id%rowtype;

----查出所有导入迷你柜编号

cursor c_mng_id is

select t.mng_id from t_yx_qdzy_mng_impl t;

r_hb_id c_hb_id%rowtype;

--查出所有导入展示板编号

cursor c_zsb_id is

select t.zsb_id from t_yx_qdzy_zsb_impl t;

r_zsb_id c_zsb_id%rowtype;

begin

--数据准备

update t_yx_qdzy_main_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_main_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_dx_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_dx_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_hb_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_hb_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_spj_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_spj_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_dzxk_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_dzxk_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_qg_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_qg_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_bg_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_bg_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_zjg_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_zjg_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_dg_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_dg_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_mng_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_mng_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_zsb_impl t set t.custcd=0||custcd where length(custcd)=7;

update t_yx_qdzy_zsb_impl t set t.custcd=substr(t.custcd,2) where length(custcd)=9;

update t_yx_qdzy_main_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_dx_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_hb_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_spj_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_dzxk_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_qg_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_bg_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_zjg_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_dg_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_mng_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_zsb_impl a set a.custnm=(select b.name from t_yx_customer b where a.custcd=b.customer_id);

update t_yx_qdzy_main_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_dx_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_hb_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_spj_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_dzxk_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_qg_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_bg_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_zjg_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_dg_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_mng_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_zsb_impl a set(a.org_id,a.compcd) = (select b.company_code,b.code||'00' from t_yx_dic_company b where b.s_name = a.orgname);

update t_yx_qdzy_main_impl t set t.if_pos=(case when t.if_pos='POS机' then '01' when t.if_pos='pc机' then '02' when t.if_pos='pos机和pc机' then '03' else '00' end);

update t_yx_qdzy_main_impl t set t.if_glrj=(case when t.if_glrj='烟草企业开发' then '01' when t.if_glrj='客户自行开发' then '02' else '00' end);

update t_yx_qdzy_main_impl t set t.network=(case when t.network='宽带上网' then '1' when t.network='拨号上网' then '2' else '0' end);

update t_yx_qdzy_main_impl t set t.space = 0 where t.space is null;

update t_yx_qdzy_main_impl t set t.tyq= '无' where t.tyq is null;

update t_yx_qdzy_main_impl t set t.dx = 0 where t.dx is null;

update t_yx_qdzy_main_impl t set t.hb = 0 where t.hb is null;

update t_yx_qdzy_main_impl t set t.spj = 0 where t.spj is null;

update t_yx_qdzy_main_impl t set t.dzxk = 0 where t.dzxk is null;

update t_yx_qdzy_main_impl t set t.qg = 0 where t.qg is null;

update t_yx_qdzy_main_impl t set t.bg = 0 where t.bg is null;

update t_yx_qdzy_main_impl t set t.zjg = 0 where t.zjg is null;

update t_yx_qdzy_main_impl t set t.dg = 0 where t.dg is null;

update t_yx_qdzy_main_impl t set t.mng = 0 where t.mng is null;

update t_yx_qdzy_main_impl t set t.zsb = 0 where t.zsb is null;

update t_yx_qdzy_dx_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_hb_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_spj_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_dzxk_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_qg_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_bg_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_zjg_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_dg_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_mng_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

update t_yx_qdzy_zsb_impl t set t.delflag=(case when t.delflag='是' then '0' else '1' end);

--判断仓储陈列是否正确

select count(1) into v_cnt from t_yx_qdzy_bg_impl t where t.bg_use = '仓储陈列' and t.quantity_tm is not null;

if(v_cnt > 0) then

mess:='PROC_YX_M_QDZY_IMPORT2:仓储陈列不计数量!';

return;

end if;

--检验数据一致性

--检验主表数量与明细数量是否一致

FOR r_custcd IN c_custcd LOOP

EXIT WHEN c_custcd%NOTFOUND;

--检查灯箱数量是否一致

select t.dx into v_cnt_dx1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.dx_id) into v_cnt_dx2 from t_yx_qdzy_dx_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_dx1 <> v_cnt_dx2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:灯箱主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_dx1||' 明细数量:'||v_cnt_dx2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:灯箱主表与明细数量不一致!';

commit;

return;

end if;

--检查海报数量是否一致

select t.hb into v_cnt_hb1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.hb_id) into v_cnt_hb2 from t_yx_qdzy_hb_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_hb1 <> v_cnt_hb2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:海报主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_hb1||' 明细数量:'||v_cnt_hb2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:海报主表与明细数量不一致!';

commit;

return;

end if;

--检查视频机数量是否一致

select t.spj into v_cnt_spj1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.spj_id) into v_cnt_spj2 from t_yx_qdzy_spj_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_spj1 <> v_cnt_spj2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:视频机主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_spj1||' 明细数量:'||v_cnt_spj2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:视频机主表与明细数量不一致!';

commit;

return;

end if;

--检查电子相框数量是否一致

select t.dzxk into v_cnt_dzxk1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.dzxk_id) into v_cnt_dzxk2 from t_yx_qdzy_dzxk_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_dzxk1 <> v_cnt_dzxk2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:电子相框主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_dzxk1||' 明细数量:'||v_cnt_dzxk2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:电子相框主表与明细数量不一致!';

commit;

return;

end if;

--检查前柜数量是否一致

select t.qg into v_cnt_qg1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.qg_id) into v_cnt_qg2 from t_yx_qdzy_qg_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_qg1 <> v_cnt_qg2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:前柜主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_qg1||' 明细数量:'||v_cnt_qg2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:前柜主表与明细数量不一致!';

commit;

return;

end if;

--检查背柜数量是否一致

select t.bg into v_cnt_bg1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.bg_id) into v_cnt_bg2 from t_yx_qdzy_bg_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_bg1 <> v_cnt_bg2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:背柜主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_bg1||' 明细数量:'||v_cnt_bg2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:背柜主表与明细数量不一致!';

commit;

return;

end if;

--检查转角柜数量是否一致

select t.zjg into v_cnt_zjg1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.zjg_id) into v_cnt_zjg2 from t_yx_qdzy_zjg_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_zjg1 <> v_cnt_zjg2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:转角柜主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_zjg1||' 明细数量:'||v_cnt_zjg2,'M');

mess:='PROC_YX_M_QDZY_IMPORT:转角柜主表与明细数量不一致!';

commit;

return;

end if;

--检查吊柜数量是否一致

select t.dg into v_cnt_dg1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.dg_id) into v_cnt_dg2 from t_yx_qdzy_dg_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_dg1 <> v_cnt_dg2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:吊柜主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_dg1||' 明细数量:'||v_cnt_dg2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:吊柜主表与明细数量不一致!';

commit;

return;

end if;

--检查迷你柜数量是否一致

select t.mng into v_cnt_mng1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.mng_id) into v_cnt_mng2 from t_yx_qdzy_mng_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_mng1 <> v_cnt_mng2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:迷你柜主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_mng1||' 明细数量:'||v_cnt_mng2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:迷你柜主表与明细数量不一致!';

commit;

return;

end if;

--检查展示板数量是否一致

select t.zsb into v_cnt_zsb1 from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

select count(t.zsb_id) into v_cnt_zsb2 from t_yx_qdzy_zsb_impl t where t.custcd = r_custcd.custcd;

if(v_cnt_zsb1 <> v_cnt_zsb2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:展示板主表与明细数量不一致,custcd='||r_custcd.custcd||' 主表数量:'||v_cnt_zsb1||' 明细数量:'||v_cnt_zsb2,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:展示板主表与明细数量不一致!';

commit;

return;

end if;

END LOOP;

--检验是否存在明仔表有主表却没有的门店情况

--灯箱

for r_dx_custcd in c_dx_custcd loop

exit when c_dx_custcd%notfound;

select count(1) into v_dx from t_yx_qdzy_main_impl t where t.custcd = r_dx_custcd.custcd;

if(v_dx = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的灯箱信息,custcd='||r_dx_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的灯箱信息!';

commit;

return;

end if;

end loop;

--海报

for r_hb_custcd in c_hb_custcd loop

exit when c_hb_custcd%notfound;

select count(1) into v_hb from t_yx_qdzy_main_impl t where t.custcd = r_hb_custcd.custcd;

if(v_hb = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的海报信息,custcd='||r_hb_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的海报信息!';

commit;

return;

end if;

end loop;

--视频机

for r_spj_custcd in c_spj_custcd loop

exit when c_spj_custcd%notfound;

select count(1) into v_spj from t_yx_qdzy_main_impl t where t.custcd = r_spj_custcd.custcd;

if(v_spj = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的视频机信息,custcd='||r_spj_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的视频机信息!';

commit;

return;

end if;

end loop;

--电子相框

for r_dzxk_custcd in c_dzxk_custcd loop

exit when c_dzxk_custcd%notfound;

select count(1) into v_dzxk from t_yx_qdzy_main_impl t where t.custcd = r_dzxk_custcd.custcd;

if(v_dzxk = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的电子相框信息,custcd='||r_dzxk_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的电子相框信息!';

commit;

return;

end if;

end loop;

--前柜

for r_qg_custcd in c_qg_custcd loop

exit when c_qg_custcd%notfound;

select count(1) into v_qg from t_yx_qdzy_main_impl t where t.custcd = r_qg_custcd.custcd;

if(v_qg = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的前柜信息,custcd='||r_qg_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的前柜信息!';

commit;

return;

end if;

end loop;

--背柜

for r_bg_custcd in c_bg_custcd loop

exit when c_bg_custcd%notfound;

select count(1) into v_bg from t_yx_qdzy_main_impl t where t.custcd = r_bg_custcd.custcd;

if(v_bg = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的背柜信息,custcd='||r_bg_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的背柜信息!';

commit;

return;

end if;

end loop;

--转角柜

for r_zjg_custcd in c_zjg_custcd loop

exit when c_zjg_custcd%notfound;

select count(1) into v_zjg from t_yx_qdzy_main_impl t where t.custcd = r_zjg_custcd.custcd;

if(v_zjg = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的转角柜信息,custcd='||r_zjg_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的转角柜信息!';

commit;

return;

end if;

end loop;

--吊柜

for r_dg_custcd in c_dg_custcd loop

exit when c_dg_custcd%notfound;

select count(1) into v_dg from t_yx_qdzy_main_impl t where t.custcd = r_dg_custcd.custcd;

if(v_dg = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的吊柜信息,custcd='||r_dg_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的吊柜信息!';

commit;

return;

end if;

end loop;

--迷你柜

for r_mng_custcd in c_mng_custcd loop

exit when c_mng_custcd%notfound;

select count(1) into v_mng from t_yx_qdzy_main_impl t where t.custcd = r_mng_custcd.custcd;

if(v_mng = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的迷你柜信息,custcd='||r_mng_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的迷你柜信息!';

commit;

return;

end if;

end loop;

--展示板

for r_zsb_custcd in c_zsb_custcd loop

exit when c_zsb_custcd%notfound;

select count(1) into v_zsb from t_yx_qdzy_main_impl t where t.custcd = r_zsb_custcd.custcd;

if(v_zsb = 0) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的展示板信息,custcd='||r_zsb_custcd.custcd,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:存在明细表有主表却没有的展示板信息!';

commit;

return;

end if;

end loop;

--数据的正式导入与更新

--灯箱

for r_dx_id in c_dx_id loop

exit when c_dx_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.dx_id,0,10) into v_custcd,v_dx_id from t_yx_qdzy_dx_impl t where t.dx_id = r_dx_id.dx_id;

if(v_custcd||'DX' <> v_dx_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:灯箱编号错误,请核对!,custcd='||v_custcd||' 灯箱编号:'||r_dx_id.dx_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:灯箱编号错误,请核对!';

return;

end if;

select count(1) into v_dx from t_yx_qdzy_dx t where t.dx_id = r_dx_id.dx_id;

if(v_dx > 0) then

update t_yx_qdzy_dx a set(a.org_id,a.custnm,a.width,a.height,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.width,b.height,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_dx_impl b where b.dx_id = r_dx_id.dx_id)

where a.dx_id = r_dx_id.dx_id;

else

select t.custcd into v_custcd from t_yx_qdzy_dx_impl t where t.dx_id = r_dx_id.dx_id;

select max(t.dx_id) into v_max_id1 from t_yx_qdzy_dx t where t.custcd = v_custcd;

select max(t.dx_id) into v_max_id2 from t_yx_qdzy_dx_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增灯箱编号错误,请核对!,custcd='||v_custcd||' 灯箱编号:'||r_dx_id.dx_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增灯箱编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_dx

select * from t_yx_qdzy_dx_impl t where t.dx_id = r_dx_id.dx_id;

end if;

end loop;

--海报

for r_hb_id in c_hb_id loop

exit when c_hb_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.hb_id,0,10) into v_custcd,v_hb_id from t_yx_qdzy_hb_impl t where t.hb_id = r_hb_id.hb_id;

if(v_custcd||'HB' <> v_hb_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:海报编号错误,请核对!,custcd='||v_custcd||' 海报编号:'||r_hb_id.hb_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:海报编号错误,请核对!';

return;

end if;

select count(1) into v_hb from t_yx_qdzy_hb t where t.hb_id = r_hb_id.hb_id;

if(v_hb > 0) then

update t_yx_qdzy_hb a set(a.org_id,a.custnm,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_hb_impl b where b.hb_id = r_hb_id.hb_id)

where a.hb_id = r_hb_id.hb_id;

else

select t.custcd into v_custcd from t_yx_qdzy_hb_impl t where t.hb_id = r_hb_id.hb_id;

select max(t.hb_id) into v_max_id1 from t_yx_qdzy_hb t where t.custcd = v_custcd;

select max(t.hb_id) into v_max_id2 from t_yx_qdzy_hb_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增海报编号错误,请核对!,custcd='||v_custcd||' 海报编号:'||r_hb_id.hb_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增海报编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_hb

select * from t_yx_qdzy_hb_impl t where t.hb_id = r_hb_id.hb_id;

end if;

end loop;

--视频机

for r_spj_id in c_spj_id loop

exit when c_spj_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.spj_id,0,10) into v_custcd,v_spj_id from t_yx_qdzy_spj_impl t where t.spj_id = r_spj_id.spj_id;

if(v_custcd||'SP' <> v_spj_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:视频机编号错误,请核对!,custcd='||v_custcd||' 视频机编号:'||r_spj_id.spj_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:视频机编号错误,请核对!';

return;

end if;

select count(1) into v_spj from t_yx_qdzy_spj t where t.spj_id = r_spj_id.spj_id;

if(v_spj > 0) then

update t_yx_qdzy_spj a set(a.org_id,a.custnm,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_spj_impl b where b.spj_id = r_spj_id.spj_id)

where a.spj_id = r_spj_id.spj_id;

else

select t.custcd into v_custcd from t_yx_qdzy_spj_impl t where t.spj_id = r_spj_id.spj_id;

select max(t.spj_id) into v_max_id1 from t_yx_qdzy_spj t where t.custcd = v_custcd;

select max(t.spj_id) into v_max_id2 from t_yx_qdzy_spj_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增视频机编号错误,请核对!,custcd='||v_custcd||' 视频机编号:'||r_spj_id.spj_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增视频机编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_spj

select * from t_yx_qdzy_spj_impl t where t.spj_id = r_spj_id.spj_id;

end if;

end loop;

--电子相框

for r_dzxk_id in c_dzxk_id loop

exit when c_dzxk_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.dzxk_id,0,10) into v_custcd,v_dzxk_id from t_yx_qdzy_dzxk_impl t where t.dzxk_id = r_dzxk_id.dzxk_id;

if(v_custcd||'XK' <> v_dzxk_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:电子相框编号错误,请核对!,custcd='||v_custcd||' 电子相框编号:'||r_dzxk_id.dzxk_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:电子相框编号错误,请核对!';

return;

end if;

select count(1) into v_dzxk from t_yx_qdzy_dzxk t where t.dzxk_id = r_dzxk_id.dzxk_id;

if(v_dzxk > 0) then

update t_yx_qdzy_dzxk a set(a.org_id,a.custnm,a.width,a.height,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.width,b.height,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_dzxk_impl b where b.dzxk_id = r_dzxk_id.dzxk_id)

where a.dzxk_id = r_dzxk_id.dzxk_id;

else

select t.custcd into v_custcd from t_yx_qdzy_dzxk_impl t where t.dzxk_id = r_dzxk_id.dzxk_id;

select max(t.dzxk_id) into v_max_id1 from t_yx_qdzy_dzxk t where t.custcd = v_custcd;

select max(t.dzxk_id) into v_max_id2 from t_yx_qdzy_dzxk_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增电子相框编号错误,请核对!,custcd='||v_custcd||' 电子相框编号:'||r_dzxk_id.dzxk_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增电子相框编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_dzxk

select * from t_yx_qdzy_dzxk_impl t where t.dzxk_id = r_dzxk_id.dzxk_id;

end if;

end loop;

--前柜

for r_qg_id in c_qg_id loop

exit when c_qg_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.qg_id,0,10) into v_custcd,v_qg_id from t_yx_qdzy_qg_impl t where t.qg_id = r_qg_id.qg_id;

if(v_custcd||'QG' <> v_qg_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:前柜编号错误,请核对!,custcd='||v_custcd||' 前柜编号:'||r_qg_id.qg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:前柜编号错误,请核对!';

return;

end if;

select count(1) into v_qg from t_yx_qdzy_qg t where t.qg_id = r_qg_id.qg_id;

if(v_qg > 0) then

update t_yx_qdzy_qg a set(a.org_id,a.custnm,a.qg_use,a.quantity_bm,a.if_shtobacco,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.qg_use,b.quantity_bm,b.if_shtobacco,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_qg_impl b where b.qg_id = r_qg_id.qg_id)

where a.qg_id = r_qg_id.qg_id;

else

select t.custcd into v_custcd from t_yx_qdzy_qg_impl t where t.qg_id = r_qg_id.qg_id;

select max(t.qg_id) into v_max_id1 from t_yx_qdzy_qg t where t.custcd = v_custcd;

select max(t.qg_id) into v_max_id2 from t_yx_qdzy_qg_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增前柜编号错误,请核对!,custcd='||v_custcd||' 前柜编号:'||r_qg_id.qg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增前柜编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_qg

select * from t_yx_qdzy_qg_impl t where t.qg_id = r_qg_id.qg_id;

end if;

end loop;

--背柜

for r_bg_id in c_bg_id loop

exit when c_bg_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.bg_id,0,10) into v_custcd,v_bg_id from t_yx_qdzy_bg_impl t where t.bg_id = r_bg_id.bg_id;

if(v_custcd||'BG' <> v_bg_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:背柜编号错误,请核对!,custcd='||v_custcd||' 背柜编号:'||r_bg_id.bg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:背柜编号错误,请核对!';

return;

end if;

select count(1) into v_bg from t_yx_qdzy_bg t where t.bg_id = r_bg_id.bg_id;

if(v_bg > 0) then

update t_yx_qdzy_bg a set(a.org_id,a.custnm,a.bg_use,a.quantity_tm,a.if_shtobacco,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.bg_use,b.quantity_tm,b.if_shtobacco,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_bg_impl b where b.bg_id = r_bg_id.bg_id)

where a.bg_id = r_bg_id.bg_id;

else

select t.custcd into v_custcd from t_yx_qdzy_bg_impl t where t.bg_id = r_bg_id.bg_id;

select max(t.bg_id) into v_max_id1 from t_yx_qdzy_bg t where t.custcd = v_custcd;

select max(t.bg_id) into v_max_id2 from t_yx_qdzy_bg_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增背柜编号错误,请核对!,custcd='||v_custcd||' 背柜编号:'||r_bg_id.bg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增背柜编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_bg

select * from t_yx_qdzy_bg_impl t where t.bg_id = r_bg_id.bg_id;

end if;

end loop;

--转角柜

for r_zjg_id in c_zjg_id loop

exit when c_zjg_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.zjg_id,0,10) into v_custcd,v_zjg_id from t_yx_qdzy_zjg_impl t where t.zjg_id = r_zjg_id.zjg_id;

if(v_custcd||'ZJ' <> v_zjg_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:转角柜编号错误,请核对!,custcd='||v_custcd||' 转角柜编号:'||r_zjg_id.zjg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:转角柜编号错误,请核对!';

return;

end if;

select count(1) into v_zjg from t_yx_qdzy_zjg t where t.zjg_id = r_zjg_id.zjg_id;

if(v_zjg > 0) then

update t_yx_qdzy_zjg a set(a.org_id,a.custnm,a.zjg_use,a.if_shtobacco,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.zjg_use,b.if_shtobacco,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_zjg_impl b where b.zjg_id = r_zjg_id.zjg_id)

where a.zjg_id = r_zjg_id.zjg_id;

else

select t.custcd into v_custcd from t_yx_qdzy_zjg_impl t where t.zjg_id = r_zjg_id.zjg_id;

select max(t.zjg_id) into v_max_id1 from t_yx_qdzy_zjg t where t.custcd = v_custcd;

select max(t.zjg_id) into v_max_id2 from t_yx_qdzy_zjg_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增转角柜编号错误,请核对!,custcd='||v_custcd||' 转角柜编号:'||r_zjg_id.zjg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增转角柜编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_zjg

select * from t_yx_qdzy_zjg_impl t where t.zjg_id = r_zjg_id.zjg_id;

end if;

end loop;

--吊柜

for r_dg_id in c_dg_id loop

exit when c_dg_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.dg_id,0,10) into v_custcd,v_dg_id from t_yx_qdzy_dg_impl t where t.dg_id = r_dg_id.dg_id;

if(v_custcd||'DG' <> v_dg_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:吊柜编号错误,请核对!,custcd='||v_custcd||' 吊柜编号:'||r_dg_id.dg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:吊柜编号错误,请核对!';

return;

end if;

select count(1) into v_dg from t_yx_qdzy_dg t where t.dg_id = r_dg_id.dg_id;

if(v_dg > 0) then

update t_yx_qdzy_dg a set(a.org_id,a.custnm,a.dg_use,a.quantity_bm,a.if_shtobacco,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.dg_use,b.quantity_bm,b.if_shtobacco,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_dg_impl b where b.dg_id = r_dg_id.dg_id)

where a.dg_id = r_dg_id.dg_id;

else

select t.custcd into v_custcd from t_yx_qdzy_dg_impl t where t.dg_id = r_dg_id.dg_id;

select max(t.dg_id) into v_max_id1 from t_yx_qdzy_dg t where t.custcd = v_custcd;

select max(t.dg_id) into v_max_id2 from t_yx_qdzy_dg_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增吊柜编号错误,请核对!,custcd='||v_custcd||' 吊柜编号:'||r_dg_id.dg_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增吊柜编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_dg

select * from t_yx_qdzy_dg_impl t where t.dg_id = r_dg_id.dg_id;

end if;

end loop;

--迷你柜

for r_mng_id in c_mng_id loop

exit when c_mng_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.mng_id,0,10) into v_custcd,v_mng_id from t_yx_qdzy_mng_impl t where t.mng_id = r_mng_id.mng_id;

if(v_custcd||'MN' <> v_mng_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:迷你柜编号错误,请核对!,custcd='||v_custcd||' 迷你柜编号:'||r_mng_id.mng_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:迷你柜编号错误,请核对!';

return;

end if;

select count(1) into v_mng from t_yx_qdzy_mng t where t.mng_id = r_mng_id.mng_id;

if(v_mng > 0) then

update t_yx_qdzy_mng a set(a.org_id,a.custnm,a.mng_use,a.quantity_bm,a.if_shtobacco,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.mng_use,b.quantity_bm,b.if_shtobacco,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_mng_impl b where b.mng_id = r_mng_id.mng_id)

where a.mng_id = r_mng_id.mng_id;

else

select t.custcd into v_custcd from t_yx_qdzy_mng_impl t where t.mng_id = r_mng_id.mng_id;

select max(t.mng_id) into v_max_id1 from t_yx_qdzy_mng t where t.custcd = v_custcd;

select max(t.mng_id) into v_max_id2 from t_yx_qdzy_mng_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增迷你柜编号错误,请核对!,custcd='||v_custcd||' 迷你柜编号:'||r_mng_id.mng_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增迷你柜编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_mng

select * from t_yx_qdzy_mng_impl t where t.mng_id = r_mng_id.mng_id;

end if;

end loop;

--展示板

for r_zsb_id in c_zsb_id loop

exit when c_zsb_id%notfound;

--检验设备编号是否正确

select t.custcd,substr(t.zsb_id,0,10) into v_custcd,v_zsb_id from t_yx_qdzy_zsb_impl t where t.zsb_id = r_zsb_id.zsb_id;

if(v_custcd||'ZB' <> v_zsb_id) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:展示板编号错误,请核对!,custcd='||v_custcd||' 展示板编号:'||r_zsb_id.zsb_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:展示板编号错误,请核对!';

return;

end if;

select count(1) into v_zsb from t_yx_qdzy_zsb t where t.zsb_id = r_zsb_id.zsb_id;

if(v_zsb > 0) then

update t_yx_qdzy_zsb a set(a.org_id,a.custnm,a.zsb_use,a.flag,a.creater,a.create_date,a.orgname,a.compcd,a.delflag,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.zsb_use,b.flag,b.creater,b.create_date,b.orgname,b.compcd,b.delflag,b.tbdate,b.updatedate from t_yx_qdzy_zsb_impl b where b.zsb_id = r_zsb_id.zsb_id)

where a.zsb_id = r_zsb_id.zsb_id;

else

select t.custcd into v_custcd from t_yx_qdzy_zsb_impl t where t.zsb_id = r_zsb_id.zsb_id;

select max(t.zsb_id) into v_max_id1 from t_yx_qdzy_zsb t where t.custcd = v_custcd;

select max(t.zsb_id) into v_max_id2 from t_yx_qdzy_zsb_impl t where t.custcd = v_custcd;

if(v_max_id1 >= v_max_id2) then

insert into t_yx_errlog(err_proname,err_type)

values('PROC_YX_M_QDZY_IMPORT2:新增展示板编号错误,请核对!,custcd='||v_custcd||' 展示板编号:'||r_zsb_id.zsb_id,'M');

mess:='PROC_YX_M_QDZY_IMPORT2:新增展示板编号错误,请核对!';

return;

end if;

insert into t_yx_qdzy_zsb

select * from t_yx_qdzy_zsb_impl t where t.zsb_id = r_zsb_id.zsb_id;

end if;

end loop;

--主表

FOR r_custcd IN c_custcd LOOP

EXIT WHEN c_custcd%NOTFOUND;

select count(1) into v_cnt from t_yx_qdzy_main t where t.custcd = r_custcd.custcd;

if(v_cnt > 0) then

update t_yx_qdzy_main a set(a.org_id,a.custnm,a.space,a.tyq,a.dx,a.hb,a.spj,a.dzxk,a.qg,a.bg,a.zjg,a.dg,a.mng,a.zsb,a.if_pos,a.if_glrj,a.network,a.creater,a.create_date,a.flag,a.orgname,a.compcd,a.tbdate,a.updatedate) =

(select b.org_id,b.custnm,b.space,b.tyq,b.dx,b.hb,b.spj,b.dzxk,b.qg,b.bg,b.zjg,b.dg,b.mng,b.zsb,b.if_pos,b.if_glrj,b.network,b.creater,b.create_date,b.flag,b.orgname,b.compcd,b.tbdate,b.updatedate from t_yx_qdzy_main_impl b where b.custcd = r_custcd.custcd)

where a.custcd = r_custcd.custcd;

else

insert into t_yx_qdzy_main

select * from t_yx_qdzy_main_impl t where t.custcd = r_custcd.custcd;

end if;

END LOOP;

commit;

mess:='导入成功!';

exception

when others then

rollback;

sqlerr:=sqlerrm;

code:=sqlcode;

insert into t_yx_errlog

(err_code,err_mess,err_proname,err_type)

values

(code,sqlerr,'PROC_YX_M_QDZY_IMPORT2','M');

commit;

end PROC_YX_M_QDZY_IMPORT2;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: