zoukankan      html  css  js  c++  java
  • Oracle(if判断)

    if (分3类)
      java 
      if (条件) {
          .... 
      }
      
      pl/sql
      if 条件 then
          .....
      end if;
    ----------------
    select * from tt3
    select age from tt3 where id=1
    ----------------------
    declare
      myage tt3.age%type;
    begin
      select age into myage from tt3 where id=1;
      --if (age>=19) {
      --   System.out.println("成年人"); 
      --}
      if myage>=19 then
          dbms_output.put_line('成年人');
      end if;
    end;
    ---------------------------
    if else
      java
      if(条件){
        ...
      }else{
        ...
      }
      
      --pl/sql
      if 条件 then
      
      else
        
      end if;
      
    declare
      myage tt3.age%type;
    begin
      select age into myage from tt3 where id=1;
      if myage>=18 then
          dbms_output.put_line('成年人');
      else
        dbms_output.put_line('未成年人');    
      end if;
    end;
    
    update tt3 set age=19 where id=1
    commit;
    -------------------------
    if else if else 
      java
      if(条件1){
         ....
      }else if(条件2) {
        ....
      }else {
      
      }
      
      --pl/sql
      if 条件1 then
        
      elsif 条件2 then
      
      else
        
      end if;
    ------------------
    declare
      myage tt3.age%type;
    begin
      select age into myage from tt3 where id=1;
      if myage>=50 then
          dbms_output.put_line('中老年人');
      elsif myage>=18 then
          dbms_output.put_line('成年的年青人');
      else
        dbms_output.put_line('未成年人');    
      end if;
    end; 
      
    -----------------
    case [selector]
        when 1 then 语句1;
        when 2 then 语句2;
        when 3 then 语句3;
        else 语句4
      end case;
      
    declare
      my_user tt3%rowtype;
    begin
      select * into my_user from tt3 where id=1;
      -- my_user.city
      case my_user.city
        when '北京' then dbms_output.put_line('长城很好玩');
        when '上海' then dbms_output.put_line('浦东很好玩');
        when '珠海' then dbms_output.put_line('南方IT最好玩');
        else
          dbms_output.put_line('不如到珠海南方玩一下');
      end case;
    end;
      
    update tt3 set city='上海' where id=1
    commit;
      
    
    
      case [selector]
        when 1 then '返回结果1';
        when 2 then '返回结果2';
        when 3 then '返回结果3';
        else '返回结果4'
      end case;
      
    ---------------
    select * from tt3 where id=1;
    --------------
    declare
      my_user tt3%rowtype;
      show_message varchar2(200);
    begin
      select * into my_user from tt3 where id=1;
      -- my_user.city
      show_message:=
      case my_user.city
        when '北京' then '长城'
        when '上海' then '浦东'
        when '珠海' then '南方'
        else '珠海南方'
      end;
      dbms_output.put_line(my_user.user_name||'('||my_user.city||')'||show_message||'很好玩');
    end;
    ----------
    declare
      my_user tt3%rowtype;
      show_message varchar2(200);
    begin
      select * into my_user from tt3 where id=1;
      show_message:=
      case 
        when my_user.age>50 then '来自于'||my_user.city|| my_user.user_name ||'是一个中老年年人'
        when my_user.age>=18 then my_user.user_name || '是一个成年人'
        else
            my_user.user_name || '是个未成年人,'||'可以到'||my_user.city||'找她'
      end;
      dbms_output.put_line(show_message);
    end;
    
    update tt3 set age=12 where id=1
    commit;
  • 相关阅读:
    scgi_params
    ngin 模块及模板
    nginx常用模块
    HTML
    nginx部署网页小游戏
    nginx的server标签还有日志管理
    关于使用yum安装的nginx的主从配置文件的碎碎念
    判断所ping主机的操作系统
    CentOS 7修改主机名
    CentOS7 设置系统时间
  • 原文地址:https://www.cnblogs.com/yuchne/p/12920751.html
Copyright © 2011-2022 走看看