PL/SQL的循环

本文记录Oracle学习过程中遇到的PL/SQL的循环~

语法格式:

while total <= 25000
loop
	total := total + 100;
end loop;

loop
	exit [when a > b];
end loop;

for i in a..b
loop
	expression;
end loop;

示例代码:

declare
	step number := 1;
begin
	while step <= 10
	loop
		dbms_output.put_line(step);
		step := step + 1;
	end loop;
end;

declare
	step number := 1;
begin
	loop
		exit when step > 10;
		dbms_output.put_line(step);
		step := step + 1;
	end loop
end;

declare
	step number := 1;
begin
	for step in 1 .. 10
	loop
		dbms_output.put_line(step);
	end loop;
end;

标签: none