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;