zoukankan      html  css  js  c++  java
  • Oracle PL/SQL 多重选择句

    Oracle中语句块的基本格式:
    declare
    --变量定义,初始化赋值。
    begin
    --变量的赋值,函数调用,if,while等。
    end;

    Oracle中的语句:关系运算符:= <>
    if 条件表达式 then
      --执行代码
    end if;

    if 条件表达式 then
      --执行代码
    else
      --执行代码
    end if;

    if 条件表达式 then
      --执行代码
      else
        if 条件表达式 then
        --执行代码
        else
        --执行代码
        end if;
    end if;

     1 declare 
     2      a number:=1;
     3      b number:=2;
     4      c number:=3;
     5      ans number:=3;
     6 begin
     7      dbms_output.put_line('选择A,B,C?');
     8      if ans=a then
     9           dbms_output.put_line('选择A');
    10      else --跟java里的else if不一样,每一个if写在一个语句块中
    11           if ans=b then
    12           dbms_output.put_line('选择B');
    13           else 
    14                if ans=c then
    15                dbms_output.put_line('选择C');
    16                else
    17                dbms_output.put_line('没有正确选择');
    18                end if;
    19           end if;
    20      end if;
    21 end;
  • 相关阅读:
    Linux进程管理
    GitHub
    MySQL存储过程
    MySQL自定义函数
    MySQL运算符和内置函数
    js类型检测
    防止SQL注入的方法
    PDO数据库抽象层
    PHP操作MySQL的常用函数
    第二周
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/3829807.html
Copyright © 2011-2022 走看看