FOR循环用于循环次数固定的情况,它会先评估循环次数,然后每次循环将计数器累加1,直至达到次数上限。示例:
declare v_name varchar2(20);
begin
for i in 1 .. 5 loop
tselect employee_name into v_name from t_employees where employee_id = i;
tdbms_output.put_line(i || '号员工是:' || v_name);
end loop;
end;
FOR循环用于循环次数固定的情况,它会先评估循环次数,然后每次循环将计数器累加1,直至达到次数上限。示例:
declare v_name varchar2(20);
begin
for i in 1 .. 5 loop
tselect employee_name into v_name from t_employees where employee_id = i;
tdbms_output.put_line(i || '号员工是:' || v_name);
end loop;
end;