• PL/SQL 条件控制


    ------ PL/SQL  条件控制   IF-THEN语句
    DECLARE 
       a number(2) := 10; 
    BEGIN 
       a:= 10; 
      -- check the boolean condition using if statement  
       IF( a < 20 ) THEN 
          -- if condition is true then print the following   
          dbms_output.put_line('a is less than 20 ' ); 
       END IF; 
       dbms_output.put_line('value of a is : ' || a); 
    END; 
    /
    ----- PL/SQL 条件控制   IF-THEN-ELSE
    DECLARE 
       a number(3) := 100; 
    BEGIN 
       -- check the boolean condition using if statement  
       IF( a < 20 ) THEN 
          -- if condition is true then print the following   
          dbms_output.put_line('a is less than 20 ' ); 
       ELSE 
          dbms_output.put_line('a is not less than 20 ' ); 
       END IF; 
       dbms_output.put_line('value of a is : ' || a); 
    END;
    
    ---- PL/SQL 条件控制 IF-THEN-ELSIF
    DECLARE 
       a number(3) := 100; 
    BEGIN 
       IF ( a = 10 ) THEN 
          dbms_output.put_line('Value of a is 10' ); 
       ELSIF ( a = 20 ) THEN 
          dbms_output.put_line('Value of a is 20' ); 
       ELSIF ( a = 30 ) THEN 
          dbms_output.put_line('Value of a is 30' ); 
       ELSE 
           dbms_output.put_line('None of the values is matching'); 
       END IF; 
       dbms_output.put_line('Exact value of a is: '|| a );  
    END;
    ---- PL/SQL 条件控制  case
    DECLARE 
       grade char(1) := 'A'; 
    BEGIN 
       CASE grade 
          when 'A' then dbms_output.put_line('Excellent'); 
          when 'B' then dbms_output.put_line('Very good'); 
          when 'C' then dbms_output.put_line('Well done'); 
          when 'D' then dbms_output.put_line('You passed'); 
          when 'F' then dbms_output.put_line('Better try again'); 
          else dbms_output.put_line('No such grade'); 
       END CASE; 
    END;
    --- PL/SQL 条件控制  可搜索case
    DECLARE 
       grade char(1) := 'B'; 
    BEGIN 
       case  
          when grade = 'A' then dbms_output.put_line('Excellent'); 
          when grade = 'B' then dbms_output.put_line('Very good'); 
          when grade = 'C' then dbms_output.put_line('Well done'); 
          when grade = 'D' then dbms_output.put_line('You passed'); 
          when grade = 'F' then dbms_output.put_line('Better try again'); 
          else dbms_output.put_line('No such grade'); 
       end case; 
    END;
    
    ---- PL/SQL  条件控制  
    
    DECLARE 
       a number(3) := 100; 
       b number(3) := 200; 
    BEGIN 
       -- check the boolean condition  
       IF( a = 100 ) THEN 
       -- if condition is true then check the following  
          IF( b = 200 ) THEN 
          -- if condition is true then print the following  
          dbms_output.put_line('Value of a is 100 and b is 200' ); 
          END IF; 
       END IF; 
       dbms_output.put_line('Exact value of a is : ' || a ); 
       dbms_output.put_line('Exact value of b is : ' || b ); 
    END;
  • 相关阅读:
    Windows 命令提示符
    力扣 ——Linked List Cycle II(环形链表 II) python实现
    力扣——Linked List Cycle(环形链表) python实现
    力扣——Copy List with Random Pointer(复制带随机指针的链表) python实现
    力扣——Reverse Nodes in k-Group(K 个一组翻转链表) python实现
    剑指offer-链表中倒数第k个结点
    剑指offer-调整数组顺序使奇数位于偶数前面
    剑指offer-数值的整数方
    剑指offer-二进制中1的个数
    剑指offer-矩形覆盖
  • 原文地址:https://www.cnblogs.com/25miao/p/10948495.html
Copyright © 2020-2023  润新知