Oracle循环语句的写法
循环语句是我们在使用Oracle数据库时用的最多的语句之一,Oracle中循环语句的写法很多,下面就让我们一起了解一下这些语句的写法。
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;
<!-- 正文结束 -->
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20854209/viewspace-1117504/
,如需转载,请注明出处,否则将追究法律责任。