Is there any way to flush output from PL/SQL in Oracle?

Viewed 79722

I have an SQL script that is called from within a shell script and takes a long time to run. It currently contains dbms_output.put_line statements at various points. The output from these print statements appear in the log files, but only once the script has completed.

Is there any way to ensure that the output appears in the log file as the script is running?

6 Answers

Set session metadata MODULE and/or ACTION using dbms_application_info().
Monitor with OEM, for example:

Module: ArchiveData
Action: xxx of xxxx

If you have access to system shell from PL/SQL environment you can call netcat:

 BEGIN RUN_SHELL('echo "'||p_msg||'" | nc '||p_host||' '||p_port||' -w 5'); END;

p_msg - is a log message v_host is a host running python script that reads data from socket on port v_port.

I used this design when I wrote aplogr for real-time shell and pl/sql logs monitoring.

Related