Oracle2DB2 的技巧和注意点
一、针对数据库:
1. 在存储过程中见分区。
在建表时使用多纬索引,使用时就不必再建了。
2. insert into ... with t1 as (select ....) , t2 as (select ....) select ..
from t1,t2 ..
MTK 无法自动转换,但 DB2 是支持此种写发的,需要手工在 emdb.db2
文件中修改。
3. 重复定义,可能是大小写问题。
在使用 mtk 从数据库中抽取数据时,排除重复的对象。
4. ‘=’号两边类型必须一致.
5. Union 操作的前后的表里的字段取名必须一致.
6. 外连接操作两边不能使用自定义函数.
7. 多个表做 cross join 后,引用同一名字的字段前要加前缀。
修改 emdb.src,在字段前加上表名。
8. 定义一个 package 作为动态游标,返回结果集。
DB2 中需要改写成定义一个返回结果集的存储过程,例如:
CREATE PROCEDURE DB2ADMIN.RETURN_RESULTSET_PROC1 (inout
inout_ret int )
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- 在 cursor 中使用 with 语句,需要改写,
-- 返回结果集
------------------------------------------------------------------------
P1: BEGIN
declare stmt varchar(1024);
--declare cur_1 cursor for (with t1 as (select id,name from sta>),t2
as (select id,name from sta>) select t1.id, from t2 left join t1 on
t1.id=t2.id);
declare cur_1 cursor WITH RETURN TO CALLER for select t1.id from
(select id,name from sta>) as t2 left join (select id,name from sta>)
as t1 on t1.id=t2.id;
open cur_1;
END P1
IBM 应用开发合作中心
1/8