--利用loop输出1到100的值并求和 ---loop exit end loop set serveroutput on; declare v_i integer:=1; v_sum integer:=0; begin loop if(v_i>100)then exit; end if; DBMS_OUTPUT.PUT_LINE(v_i); v_sum:=v_sum+v_i; v_i:=v_i+1; end loop; DBMS_OUTPUT.PUT_LINE(‘sum is‘||v_sum); end; ----------------- --loop 代码 exit when 条件; end loop declare v_i integer :=1; v_sum integer:=0; begin loop exit when v_i>100; v_sum :=v_sum+v_i; v_i:=v_i+1; end loop; DBMS_OUTPUT.PUT_LINE(‘sun is‘||v_sum); end; ---while 条件 loop 代码 end loop declare v_i integer :=1; v_sum integer:=0; begin while v_i<=100 loop v_sum :=v_sum+v_i; v_i:=v_i+1; end loop; DBMS_OUTPUT.PUT_LINE(‘sun is‘||v_sum); end; --for in... declare v_s integer:=0; begin for i in 1..100 loop v_s:=v_s+i; end loop; DBMS_OUTPUT.PUT_LINE(v_s); end;