zoukankan      html  css  js  c++  java
  • 教你快速把握Oracle SQL到DB2 SQL的移植1

     
    Oracle SQL到DB2 SQL的移植:
    1、Oracel中的"decode"
    DB2的措置方案:用"case"条件表达式来完成。

    "case"两种语法的情势:

    (1)CASE

    WHEN 条件 THEN 后果1
    ELSE 后果2
    END
     

    (2)CASE 表达式1

    WHEN 表达式2 THEN 后果1
    ELSE 后果2
    END
     

    上面的WHEN可以重复频频,就像C中的SWITCH ..CASE的表达.

    例如:

    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
    使用实例:
    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;
     
     
    来自: 新客网(www.xker.com) 详文参考:http://www.xker.com/page/e2008/0128/46641.html


    版权声明: 原创作品,答理转载,转载时请务必以超链接方式标明文章 原始来因 、作者信息和本声明。否则将清查法律责任。

  • 相关阅读:
    经典javascript
    大话prototype
    DataTable使用方法总结
    实验四 Web服务器1socket编程
    2.4 OpenEuler中C语言中的函数调用测试
    20191323王予涵第13章学习笔记
    20191323王予涵第十三章学习笔记
    2.5 OpenEuler 中C与汇编的混合编程
    个人贡献
    20191323王予涵第十二章学习笔记
  • 原文地址:https://www.cnblogs.com/zgqjymx/p/1975431.html
Copyright © 2011-2022 走看看