现在我有个工作是将SQL Server移植到Oracle数据库,其中急切想知道有关数据库特有函数的问题。
据我在SQL Server开发中,用到了这样几个函数
1. isnull(column, 0)
2. charindex(A, B)
3. case when ...
       then ...
       else ...
       end
4. case ... when ... then ...
            when ... then ...
            else
            end
这时,我想知道Oracle中是否与上述SQL Server的函数用法相同?如不,可用Oracle中怎样的函数去取代它们?
在这请大家帮个忙,谢谢大家。

解决方案 »

  1.   

    1   if column is null or column='' then ....end if;2   INSTR(str1,str2,i,j)
      str1,str2均为字符串,i,j为整数。函数返回str2在str1中第j次出现的位置,搜索从  
        str1的第i个字符开始。当没有发现需要的字符时返回0,如果i为负数,那么搜索将从右到
        左进行,但是位置的计算还是从左到右,i和j的缺省值为1.
        
        n int;
        n:=instr('ABCDB','B',1,1);
        此时n return 2;
        如n:=instr('ABCDB','B',1,2);
        n return 53,4 不太清楚SQL中的含义 ORACLE中一般都是用   if ....then
        elsif ....then
        ....
        end if;
      

  2.   

    很谢谢chanet(牧师)和caral525(猫猫)。
    不过chanet(牧师)的nvl(column,item)可否详细说明下。
    caral525(猫猫)你的1.的if then语句我已经知道,但我现在是希望有个像SQL SERVER函数isnull(columname, 0)那样对一个字段值判断,如果该字段为null值,那么我就用0来代替,如果不为空,就得到原值。
    并且case ... when ... then ...  是个比较重要的判断句;譬如case某一个字段,when该字段等于A时,then将该值赋为0,when该字段等于B时,then将该值赋为1。
    点数会在封贴时一并分发。
      

  3.   


        SQL  Server              Oracle   
    1.   isnull(column,0)         nvl(column,0)
    2.   charindex                instr
    3.   case ... when            decode or strill using 'case when'    decode(条件判断式,值1,输出1,值2,输出2,... 缺省值)