- 最后登录
- 2014-7-7
- 在线时间
- 65 小时
- 威望
- 23
- 金钱
- 172
- 注册时间
- 2012-5-15
- 阅读权限
- 10
- 帖子
- 36
- 精华
- 1
- 积分
- 23
- UID
- 430
|
1#
发表于 2012-7-16 10:56:46
|
查看: 5457 |
回复: 2
create or replace procedure proc_card_segment_gj(v_province_id in number,
--v_area_id in number,
v_result out varchar2)
is
-----v_result varchar(200)
begin
if v_province_id is null then
v_result :='割接省分编码不能为空';
return;
end if;
--card_segment_76
--部门合并
begin
update /*+ parallel(a,16) */ card_segment_76 a set a.depot_id=(select b.newolddeptid
from tab_office_mutil_dept b
where a.depot_id=b.olddepartid)
where exists (select 1
from tab_office_mutil_dept b
where a.depot_id=b.olddepartid)
and exists (select 1 from province_config_gj pcg
where a.province_id=pcg.province_id
and a.area_id=pcg.areaid
and pcg.flag='1')
and a.province_id=v_province_id;
exception
when others then
v_result :='card_segment_76 业务表中部门多个旧编码更新成同一个旧编码失败';
return;
commit;
end;
--渠道合并
begin
update /*+ parallel(a,16) */ card_segment_76 a set a.depot_id=(select b.newoldchanid
from agent_channel_mutil_chan b
where a.depot_id=b.oldchanid)
where exists (select 1
from agent_channel_mutil_chan b
where a.depot_id=b.oldchanid)
and exists (select 1 from province_config_gj pcg where
a.province_id=pcg.province_id
and a.area_id=pcg.areaid
and pcg.flag='1')
and a.province_id=v_province_id;
exception
when no_data_found then
null;
when others then
v_result :='card_segment_76 业务表中渠道多个旧编码更新成同一个旧编码失败' || sqlerrm ;
return;
commit;
end;
--card_segment_76
--更新老库位为新库位,更新老区域为新库位对应的新区域
begin
update /*+ parallel(ct,16) */ card_segment_76 ct set (ct.depot_id,ct.area_id,ct.county_id)=(select ts.depart_code,ts.city_code,ts.county_code from tab_store_2_dept_code ts
where ct.depot_id=ts.old_store_code
and ct.province_id=ts.prov_code
and ct.area_id=ts.city_code)
where exists (select 1 from tab_store_2_dept_code ts
where ct.depot_id=ts.old_store_code
and ct.province_id=ts.prov_code
and ct.area_id=ts.city_code)
and exists (select 1 from province_config_gj pcg where
ct.province_id=pcg.province_id
and ct.area_id=pcg.areaid
and pcg.flag='1')
and ct.province_id=v_province_id;
exception
when others then
v_result :='card_segment_76 更新老库位为对应的新库位失败';
return;
commit;
end;
--更新 real_county_id
--更新老区县编码为新区县编码
begin
update /*+ parallel(tu,16) */ card_segment_76 tu set tu.real_county_id =
(select tj.countyid from tab_county tj
where tu.real_county_id=tj.oldcountyid
and tu.area_id=tj.areaid)
where exists (select 1 from tab_county tj
where tu.real_county_id=tj.oldcountyid
and tu.area_id=tj.areaid)
and exists (select 1 from province_config_gj pcg where
tu.area_id=pcg.areaid
and tu.province_id=pcg.province_id
and pcg.flag='1')
and tu.real_county_id is not null
and tu.province_id=v_province_id;
exception
when others then
v_result :='更新card_segment_76 表 real_county_id 编码失败' || sqlerrm;
ROLLBACK;
return;
commit;
end;
v_result :='成功';
commit;
end;
报错ora 12838,开始是全部修改后最后提交,后来看到报错信息后修改为更新完成后单独提交。但还是报错 |
|