if  temp1  is  null  then    
   if  temp2  is  null  then  
       Result:=  111;  
   else  
       Result:=temp2;
   end if; 
else  
   Result:=temp1;  
end  if;

解决方案 »

  1.   

    if temp1 is null then 
      if temp2 is null then
      Result:= 111
      else Result:=temp2
    else Result:=temp1
    end if;改为:if temp1 is null then 
      if temp2 is null then
        Result:= 111;
      else 
        Result:=temp2;
      end if;
    else 
      Result:=temp1;
    end if;
      

  2.   

    我这样改了之后,然后再slect get_value('143214','1232','12324') from dual;
    不管这几个参数改成什么,竟然都是得出的同样的值。
      

  3.   

    同样的值?是什么?是111,temp1还是temp2呢?
    针对一组具体参数,一步步分析一下,看应该得到什么,实际得到什么。
      

  4.   

    是得出来的Result竟然是同样的值,我也不知道它给的是那个值。反正把函数改成原来的都不行了!
    单独查一个SQL可以。
      

  5.   

    create or replace function f_manage_qxjd(as_start in number) return varchar2 is
    /*
      函数功能描述:
          获得井段数
          满足条件的单井的单条钻井取芯中的起始井深到终止井深和
              0-1000米
              1001-1500米
              1501-2000米
              2001-2500米
              2501-3000米
              3001-3500米
              3501-4000米
              4001-5000米
              5001-6000米
              6001-7000米
              7000米 以上
       返回值:井段范围
    */
      v_count varchar2(20);--井段范围begin
      --Based on the qsjs,choose a course
      if as_start<=1000 then
        v_count:='0-1000m';
      elsif as_start>1000 and as_start<=2500 then
        v_count:='1001-2500m';
      elsif as_start>2500 and as_start<=3000 then
        v_count:='2501-3000m';
      elsif as_start>3000 and as_start<=3500 then
        v_count:='3001-3500m';
      elsif as_start>3500 and as_start<=4000 then
        v_count:='3501-4000m';
      elsif as_start>4000 and as_start<=4500 then
        v_count:='4001-4500m';
      elsif as_start>4500 and as_start<=5000 then
        v_count:='4501-5000m';
      elsif as_start>5000 and as_start<=5500 then
        v_count:='5001-5500m';
      elsif as_start>5500 and as_start<=6000 then
        v_count:='5501-6000m';
      elsif as_start>6000 and as_start<=6500 then
        v_count:='6001-6500m';
      elsif as_start>6500 and as_start<=7000 then
        v_count:='6501-7000m';
      else
       if as_start>7000 then
          v_count:='7000m以上';
        end if;
      end if;
       return(v_count);
    end f_manage_qxjd;
      

  6.   

    根据一步步的调试发现是参数传得有问题
    create or replace function get_value(
    omc_id in neobject.omc_id%TYPE,
    object_class in  neobject.object_class%TYPE)
    return objects.int_id%type isResult objects.int_id%type;
    temp1 objects.int_id%type;
    temp2 objects.int_id%type;
    ===================================
    omc_id和object_class都是传入的参数,要不要in 啊?