Sorry the silly question. I am stuck with Dbms_Output:
First I tried it within a batch/sqlplus call. But the spool file would only contain the message "pl/sql sucessfully executed". (See first code part)
I am running the code on Oracle Database 12c Enterprise Edition Release 12.1.0.2.0
Spool D:\log\spool.txt
Declare
Some_Num Number := 5;
Begin
Dbms_Output.Enable(1000000);
Dbms_Output.Put_Line('Id, Timestamp');
For Rec In
(
Select 1 As Id, Sysdate As Timestamp From Dual
Union
Select 2 As Id, Sysdate As Timestamp From Dual
Union
Select 3 As Id, Sysdate As Timestamp From Dual
Union
Select 4 As Id, Sysdate As Timestamp From Dual
)
Loop
Dbms_Output.Put_Line( Rec.Id || ', ' || Rec.Timestamp );
-- some code here was actually executed;
End Loop;
--Dbms_Output.Disable;
Exception
When Others Then
Null;
Dbms_Output.Put_Line('Error');
--Dbms_Output.Disable;
End;
/
Spool Off
exit;