How to print logs in unix prompt or to a log file?

I am executing a stored procedure through shell script. In the procedure, i have dbms_output.put_line to log the comments. This is working fine and but logs are available only after the execution of the pl/sql procedure's completion.

I want to print the log comments while executing the procedure itself. is there a way to do it?

---------- Post updated at 02:46 AM ---------- Previous update was at 02:03 AM ----------

Shell script

logs=$root"/logs"
DATE=`date '+%Y%m%d'`
exec >> $logs/subprod_${DATE}.log 2>&1
sqlplus -s $user/$pass@$tns @$sql/inv_proce.sql << EOF
EOF

SQL file (nv_proce.sql )

set pages 0
set trimspool on
set serveroutput on
set echo on
set feedback on
set heading on
variable out NUMBER
begin
        pack.proce(:out);
end;
/

Hi

That is how dbms_output.put_line works. it keeps everything in the buffer, and at the end of the procedure, it is flushed out.

You can check with UTL_FILE package wherein you actually can write the message to the OS file. THis should help you.

Guru

1 Like

But i don't want the logs to be available at Server, i need it at the client. The problem stored procedure is getting invoked but it just gets running for a very long time. I couldn't able to figure out where exactly it is running or it is failed with exception or errors. Same scripts running good in lower env.