1、loop
declare x number:= 0; begin x:=0;
loop x:=x+1; /*if x>=10 then exit; end if;*/ exit when x>10; -- 此句与上面的if语句作用相同,但这样简练。 DBMS_OUTPUT.PUT_LINE('内 :x='||x); end loop;
DBMS_OUTPUT.PUT_LINE('外:x='||x); end;
2、while
declare x number; begin x:=0;
while x<=10 loop x:=x+1; DBMS_OUTPUT.PUT_LINE('内:x='||x); end loop;
DBMS_OUTPUT.PUT_LINE('外:x='||x); end;
3、for
begin for x in reverse 1..10 loop -- reverse大到小 DBMS_OUTPUT.PUT_LINE('内:x='||x); end loop;
DBMS_OUTPUT.PUT_LINE('endget'); end;
4、goto
declare x number; begin x:=0;
<<repeat_loop>> begin x:=x+1; DBMS_OUTPUT.PUT_LINE('内:x='||x); end;
if x<=10 then goto repeat_loop; end if;
DBMS_OUTPUT.PUT_LINE('外:x='||x); end;
|