Oracle循环语句

Oracle循环语句种类很多,下面就为您详细介绍几种常用的Oracle循环语句的写法,如果您对Oracle循环语句方面感兴趣的话,不妨一看。

loop循环:

 
 
  1. create or replace procedure pro_test_loop is
  2. i number;
  3. begin
  4. i:=0;
  5. loop
  6. ii:=i+1;
  7. dbms_output.put_line(i);
  8. if i>5 then
  9. exit;
  10. end if;
  11. end loop;
  12. end pro_test_loop;

while循环:

 
 
  1. create or replace procedure pro_test_while is
  2. i number;
  3. begin
  4. i:=0;
  5. while i<5 loop
  6. ii:=i+1;
  7. dbms_output.put_line(i);
  8. end loop;
  9. end pro_test_while;
  10. 循环5次,并打印出来。

for循环1:

 
 
  1. create or replace procedure pro_test_for is
  2. i number;
  3. begin
  4. i:=0;
  5. for i in 1..5 loop
  6. dbms_output.put_line(i);
  7. end loop;
  8. end pro_test_for;

for循环2:

 
 
  1. create or replace procedure pro_test_cursor is
  2. userRow t_user%rowtype;
  3. cursor userRows is
  4. select * from t_user;
  5. begin
  6. for userRow in userRows loop
  7. dbms_output.put_line(userRow.Id||','||userRow.Name||','||userRows%rowcount);
  8. end loop;
  9. end pro_test_cursor;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值