呵呵,循环好像只能使用while declare @count int set @count=1 while(@count!=200) { print @count; set @count=@conut+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;while循环: create or replace procedure pro_test_while is i number; begin i:=0; while i<5 loop i:=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;
fetch c_sales_bonus
into v_storecode, v_staffcode, v_title, v_bonus;
insert into hr_bonus
(staffcode, storecode, bonus_month, bonus, title, issales)
values
(v_staffcode, v_storecode, p_month, v_bonus, v_title, 'Y');
exit when c_sales_bonus%notfound;
end loop;
declare @count int
set @count=1
while(@count!=200)
{
print @count;
set @count=@conut+1
}
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;while循环:
create or replace procedure pro_test_while is
i number;
begin
i:=0;
while i<5 loop
i:=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;
要是不行就用C#写DLL,来调用
那么存储过程中还有没有其他的循环语句
可直接写循环,或使用游标
select @i=0
while @i<=9
begin
set @j=0
while @j<=9
begin
insert into temp3 select @i,@j
set @j=@j+1
end
set @i=@i+1
end
3个的区别是什么 既然能混合使用 几乎没区别
只是使用的地方不一样
貌似有点像IF 和SWITCH.
使用的地方不一样而已
换一个用不是不可以.只是添加点复杂度.