- 论坛徽章:
- 1
|
需求:需要将informix数据库中的存储过程通过shell脚本自动转化为oracle中的存储过程
informix存储样例:- drop procedure circuit_tmp_update();
- create procedure circuit_tmp_update();
- define objectid_v varchar(128);
- define circuitnumber_v varchar(128);
- define aendzhandianobjectid_v varchar(128);
- define zendzhandianobjectid_v varchar(128);
- define aendswitchbuildingobjectid_v varchar(128);
- define zendswitchbuildingobjectid_v varchar(128);
- define rel_zhandian_id_v varchar(128);
- define zd varchar(128);
- define id varchar(128);
- set debug file to '/home/informix/yuy/circuit_tmp_update.log';
- --开启跟踪所有执行的语句
- trace on;
- trace '开始执行存储过程';
- begin
- --异常捕捉
- on exception
- rollback work;
- return;
- end exception
- begin work;
- --1、创建临时表
- trace '开始创建tmp_table_circuit_a表';
- create table tmp_table_circuit_a(
- objectid varchar(128),
- circuitnumber varchar(128),
- rel_zhandian_id varchar(128),
- aendswitchbuildingobjectid varchar(128));
- trace 'tmp_table_circuit_a表创建完成';
- trace '开始创建tmp_table_circuit_z表';
- create table tmp_table_circuit_z(
- objectid varchar(128),
- circuitnumber varchar(128),
- rel_zhandian_id varchar(128),
- zendswitchbuildingobjectid varchar(128));
- trace 'tmp_table_circuit_z表创建完成';
- --查询circuit表中zhandianid为空的数据
- foreach c0
- for select objectid,circuitnumber,aendzhandianobjectid,zendzhandianobjectid,aendswitchbuildingobjectid,zendswitchbuildingobjectid
- into objectid_v,circuitnumber_v,aendzhandianobjectid_v,zendzhandianobjectid_v,aendswitchbuildingobjectid_v,zendswitchbuildingobjectid_v from circuit
- --如果circuit表中aswitchbuildingobjectid不为空,则根据aswitchbuildingobjectid找到jifang表中的rel_zhandian_id
- trace '开始查询符合条件的A端数据';
- if aendswitchbuildingobjectid_V != '' and aendswitchbuildingobjectid_V != 'null' then
- select rel_zhandian_id into rel_zhandian_id_v from jifang where objectid=aendswitchbuildingobjectid_v;
- insert into tmp_table_circuit_a values (objectid_v,circuitnumber_v,rel_zhandian_id_v,aendswitchbuildingobjectid_v);
- end if;
- trace 'A端数据更新完成';
- --如果circuit表中zswitchbuildingobjectid不为空,则根据zswitchbuildingobjectid找到jifang表中的rel_zhandian_id
- trace '开始查询符合条件的Z端数据';
- if zendswitchbuildingobjectid_V != '' and zendswitchbuildingobjectid_V != 'null' then
- select rel_zhandian_id into rel_zhandian_id_v from jifang where objectid=zendswitchbuildingobjectid_v;
- insert into tmp_table_circuit_z values (objectid_v,circuitnumber_v,rel_zhandian_id_v,zendswitchbuildingobjectid_v);
- end if;
- trace 'Z端数据更新完成';
- end foreach;
- --更新A端数据
- foreach c0
- for select objectid,rel_zhandian_id into id,zd from tmp_table_circuit_a
- update circuit set aendzhandianobjectid=zd where objectid=id;
- end foreach;
- --更新Z端数据
- foreach c0
- for select objectid,rel_zhandian_id into id,zd from tmp_table_circuit_z
- update circuit set zendzhandianobjectid=zd where objectid=id;
- end foreach;
- --5、提交事务
- commit work;
- end;
- trace '存储过程执行完毕';
- --关闭跟踪
- trace off;
- end procedure;
- execute procedure circuit_tmp_update();
复制代码 informix存储过程迁移oracle的异同,希望能够在这里与大家讨论下这个是否可以直接写个shell脚本自动转换
http://woying.me/blog/rewrite.php/read-265.html |
|