oracle循环怎么写,oracle存储过程循环怎么写

oracle存储过程循环怎么写

mip版  关注:173  答案:2  悬赏:40

解决时间 2021-01-18 03:33

dbf1be4ce24567b1f279326f3e16f01b.png

已解决

2021-01-18 00:13

oracle存储过程循环怎么写

最佳答案

61b5b16bafebed1e50ea275b635f08eb.png

2021-01-18 01:04

Oracle中有三种循环(For、While、Loop):

1、loop循环:

create or replace procedure pro_test_loop is

i number;

begin

i:=0;

loop

i:=i+1;

dbms_output.put_line(i);

if i>5 then

exit;

end if;

end loop;

end pro_test_loop;

2、while循环:

create or replace procedure pro_test_loop is

i number;

begin

i:=0;

while i<5 loop

i:=i+1;

dbms_output.put_line(i);

end loop;

end pro_test_loop ;

3、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;

4、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;

全部回答

31bdeb04ed83ef1548b3905291d2f9f5.png

1楼

2021-01-18 01:35

oracle中有三种循环(for、while、loop):

1、loop循环:

create or replace procedure pro_test_loop is

i number;

begin

i:=0;

loop

i:=i+1;

dbms_output.put_line(i);

if i>5 then

exit;

end if;

end loop;

end pro_test_loop;

2、while循环:

create or replace procedure pro_test_loop  is

i number;

begin

i:=0;

while i<5 loop

i:=i+1;

dbms_output.put_line(i);

end loop;

end pro_test_loop;

3、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;4、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;

我要举报

如果感觉以上信息为低俗/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!

点此我要举报以上信息!

推荐资讯

大家都在看

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值