Oracle循環語句種類很多,下面就為您詳細介紹幾種常用的Oracle循環語句的寫法,如果您對Oracle循環語句方面感興趣的話,不妨一看。
loop循環:
- create or replace procedure pro_test_loop is
- i number;
- begin
- i:=0;
- loop
- ii:=i+1;
- dbms_output.put_line(i);
- if i>5 then
- exit;
- end if;
- end loop;
- end pro_test_loop;
while循環:
- create or replace procedure pro_test_while is
- i number;
- begin
- i:=0;
- while i<5 loop
- ii:=i+1;
- dbms_output.put_line(i);
- end loop;
- end pro_test_while;
for循環1:
- create or replace procedure pro_test_for is
- i number;
- begin
- i:=0;
- for i in 1..5 loop
- dbms_output.put_line(i);
- end loop;
- end pro_test_for;
for循環2:
- create or replace procedure pro_test_cursor is
- userRow t_user%rowtype;
- cursor userRows is
- select * from t_user;
- begin
- for userRow in userRows loop
- dbms_output.put_line(userRow.Id||','||userRow.Name||','||userRows%rowcount);
- end loop;
- end pro_test_cursor;