SQL> set serveroutput on
SQL> declare
2 ctr integer:=0;
3 begin
4 while ctr<10 loop
5 dbms_output.put(to_char(ctr) || ' ');
6 ctr:=ctr+1;
7 end loop;
8 dbms_output.put_line('Loop Exited');
9 end;
10 /
0 1 2 3 4 5 6 7 8 9 Loop ExitedPL/SQL 过程已成功完成。
SQL> declare
2 ctr integer:=0;
3 begin
4 while ctr<10 loop
5 dbms_output.put(to_char(ctr) || ' ');
6 ctr:=ctr+1;
7 end loop;
8 dbms_output.put_line('Loop Exited');
9 end;
10 /
0 1 2 3 4 5 6 7 8 9 Loop ExitedPL/SQL 过程已成功完成。
2、将PL/SQL语句块写入文件,然后调入SQLPLUS执行。jl-supp:/home/jl-supp/sql>cat for.sql
set serveroutput on
declare
ctr integer:=0;
begin
dbms_output.enable;
for ctr in 0..9 loop
dbms_output.put(to_char(ctr) || ' ');
end loop;
dbms_output.put_line('Loop Exited');
end;
/
SQL> @for.sql
0 1 2 3 4 5 6 7 8 9 Loop ExitedPL/SQL procedure successfully completed.