内容摘要:本文针对从Oracle到DB2数据移植过程中需注意问题进行了解析
2、Oracle中的Start with...Connect By递归查询
DB2解决方案:用with公共递归表达式来解决。
DB2解决方案:用case条件表达式完成。
Oracle SQL:
selectt.id
froma_organt
startwitht.idin(selectdecode(t.organtypecode,
''D'',
t.parent,
''S'',
t.parent,
t.id)
fromA_ORGAN
wheret.id=35)
connectbyt.parent=priort.id
DB2SQL:
WITHFKK(id)as
(selecto.idfroma_organo
whereo.id=35
UNIONALL
selectcasex.organtypecode
when''D''thenx.parent
when''S''thenx.parent
elsex.id
end
fromFKKfk,a_organx
wherefk.id=x.parent)
selectdistinctidfromFKK;
3、Oracle中的dual表对应DB2中的SYSIBM.SYSDUMMY1表
DB2解决方案:对应于DB2中的 SYSIBM.SYSDUMMY1表
Oracle SQL:
-------------------------
select 15 as ttt from dual
结果:
ttt
-------
15
DB2 SQL:
-------------------------
select 15 as ttt from SYSIBM.SYSDUMMY1
结果:
ttt
-------
15
4、日期转换问题
DB2解决方案:有相应的函数
Oracle SQL:
selectm.*
fromdj_mcdjm
wherem.mcqc||''''like''%$P%''
andm.xzqhdm||''''like''%$P%''
andm.hylbdm||''''like''%$P%''
andm.blqsrq>=to_date(''$P'',''yyyy-mm-dd'')
andm.blqsrq<to_date(''$P'',''yyyy-mm-dd'')+1
责编:豆豆技术应用