DB version: 12.1
For the below basic loop , I was expecting to print one line to be printed every 20 seconds (for each iteration). Instead, it waits for 60 seconds (3 loops) and prints all 3 lines together ! Why is that ?
SQL> set serveroutput on
SQL> alter session set nls_Date_format='DD-MON-YYYY HH24:MI:SS';
Session altered.
declare
v_date date;
begin
for i in 1..3
loop
dbms_lock.sleep(20);
select sysdate into v_date from dual;
dbms_output.put_line('the date is '||v_date||'--'||i);
end loop;
end;
/
Output :
the date is 16-DEC-2016 15:55:52--1
the date is 16-DEC-2016 15:56:12--2
the date is 16-DEC-2016 15:56:32--3