create or replace procedure times is
ii positive:=1;
begin
loop
dbms_lock.sleep(1);
dbms_output.put_line(ii||' '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
ii:=ii+1;
exit when ii>10;
end loop;
end;
/

 结果:

SQL> exec times;
1 2016-10-08 11:26:57
2 2016-10-08 11:26:58
3 2016-10-08 11:26:59
4 2016-10-08 11:27:00
5 2016-10-08 11:27:01
6 2016-10-08 11:27:02
7 2016-10-08 11:27:03
8 2016-10-08 11:27:04
9 2016-10-08 11:27:05
10 2016-10-08 11:27:06

PL/SQL 过程已成功完成。

posted on 2016-10-08 11:29  风吹羽  阅读(6981)  评论(0编辑  收藏  举报