Oracle 过程控制语句整理

分支语句/循环语句


v_case number(3) := 100;

begin

  if 2 < 1 then
  
    dbms_output.put_line('条件成立');
  
  elsif 4 > 3 then
  
    if 7 < 6 then
    
      dbms_output.put_line('条件不成立1');
    end if;
  
  elsif 6 > 5 then
  
    dbms_output.put_line('条件不成立2');
  
  else
  
    dbms_output.put_line('条件不成立3');
  
  end if;
  
  case v_case
    
  when 1 then
    dbms_output.put_line('条件成立1');
    when 100 then
      
    dbms_output.put_line('条件成立100');
    else
      
    dbms_output.put_line('条件不匹配');
    
  end case;
  
  
  case
    
  when 8 > 7 then
    
  dbms_output.put_line('8 > 7成立');
  when 9 > 8 then
    dbms_output.put_line('9 > 8成立');
    
    else
      dbms_output.put_line('都不成立');
      
      end case;
      
      <<loop1>>
      loop
        
      v_case := v_case - 1;
      
      dbms_output.put_line('v_case = ' || v_case);
      
      --if (v_case = 90) then
        
      --dbms_output.put_line('退出循环');
        
      exit loop1 when v_case = 90;
      
      --end if;
      
      end loop;
      
      while v_case > 80
      loop
        
      v_case := v_case - 1;
      
      dbms_output.put_line('v_case = ' || v_case);
      
      end loop;
      
      for inx in reverse 1 .. 10 loop
        
      v_case := v_case + inx;
      
      dbms_output.put_line('v_case = ' || v_case);
      
      end loop;

end pr_test1;
/
原文地址:https://www.cnblogs.com/shadowduke/p/4929087.html