--if then elsif then end if; declare a number; b varchar2(10); begin a := 2; if a=1 then b :='a'; elsif a=2 then b := 'b'; else b := 'c'; end if; Dbms_Output.put_line('b is '|| b); end; --case when declare a number; b varchar2(10); begin a := 2; case when a=1 then b := 'a'; when a=2 then b := 'b'; when a=3 then b := 'c'; else b := 'others'; end case; dbms_output.put_line('b is '|| b); end;
--loop end loop declare x number; begin x := 0; loop x := x+ 1; if x >=3 then exit; end if; dbms_output.put_line('内:x='||x); end loop; dbms_output.put_line('外:x='||x); end;
--exit when 方式 declare x number; begin x:= 0; loop x:=x+1; exit when x>=3; dbms_output.put_line('内:x='||x); end loop; dbms_output.put_line('外:x='||x); end;
begin for i in reverse 1..5 loop dbms_output.put_line('i='||i); end loop; dbms_output.put_line('end of for loop'); end;