新聞中心
以下的文章主要是對Oracle SQL到DB2 SQL移植解決方案淺析,Oracle SQL到DB2 SQL移植現(xiàn)已變得十分搶手,如果你想知道更多的關(guān)于其實(shí)際應(yīng)用方面的知識,你就可以瀏覽下面的文章,相信會對你有所幫助。

創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括齊河網(wǎng)站建設(shè)、齊河網(wǎng)站制作、齊河網(wǎng)頁制作以及齊河網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,齊河網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到齊河省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
1、Oracel中的decode
DB2解決方案:用case條件表達(dá)式完成。
case兩種語法模式:
(1)CASE
WHEN 條件 THEN 結(jié)果1
ELSE 結(jié)果2
END
(2)CASE 表達(dá)式1
WHEN 表達(dá)式2 THEN 結(jié)果1
ELSE 結(jié)果2
END
上面的WHEN可以重復(fù)多次,就像C中的SWITCH ..CASE的表達(dá).
例如:
- SELECT ORDNO,CUSNO,
- CASE MONTH(SHIPDATE)
- WHEN ′′01′′ THEN ′′Jan′′
- WHEN ′′02′′ THEN ′′Feb′′
- WHEN ′′03′′ THEN ′′Mar′′
- WHEN ′′04′′ THEN ′′Apr′′
- WHEN ′′05′′ THEN ′′May′′
- WHEN ′′06′′ THEN ′′Jun′′
- WHEN ′′07′′ THEN ′′Jul′′
- WHEN ′′08′′ THEN ′′Aug′′
- WHEN ′′09′′ THEN ′′Sep′′
- WHEN ′′10′′ THEN ′′Oct′′
- WHEN ′′11′′ THEN ′′Nov′′
- WHEN ′′12′′ THEN ′′Dec′′
- END
- FROM FILE
應(yīng)用實(shí)例:
Oracle SQL:
- select decode(t.organtypecode,
′′D′′, t.parent, ′′S′′, t.parent, t.id)- from A_ORGAN t
- where t.parent = 35
- DB2 SQL:
- select case x.organtypecode
- when ′′D′′ then
- x.parent
- when ′′S′′ then
- x.parent
- else
- x.id
- end
- from a_Organ x
- where x.parent = 35;
2、Oracle中的Start with...Connect By遞歸查詢
DB2解決方案:用with公共遞歸表達(dá)式來解決。
DB2解決方案:用case條件表達(dá)式完成。
Oracle SQL:
- select t.id
- from a_organ t
- start with t.id in (select decode(t.organtypecode,
- ′′D′′,
- t.parent,
- ′′S′′,
- t.parent,
- t.id)
- from A_ORGAN
- where t.id = 35)
- connect by t.parent = prior t.id
- DB2 SQL:
- WITH FKK(id) as
- (select o.id from a_organ o
- where o.id=35
- UNION ALL
- select case x.organtypecode
- when ′′D′′ then x.parent
- when ′′S′′ then x.parent
- else x.id
- end
- from FKK fk, a_organ x
- where fk.id=x.parent)
- select distinct id from FKK;
上述的相關(guān)內(nèi)容就是對Oracle SQL到DB2 SQL移植解決方案的描述,希望會給你帶來一些幫助在此方面。
分享題目:對OracleSQL到DB2SQL移植的淺析
本文鏈接:http://www.dlmjj.cn/article/dpogjcg.html


咨詢
建站咨詢
