Is there anyway we can write/capture the dbms outputs in a log file? I have a procedure run from the program and it has dbms in it.. Where the output will be saved when executed? Please guide
            Asked
            
        
        
            Active
            
        
            Viewed 886 times
        
    -1
            
            
        - 
                    You need to put an example of your code. Your question , without it, is too vague. – Andy K Dec 28 '14 at 08:16
 - 
                    1Put `SET SERVEROUTPUT ON;`before the `declare` statement – Andy K Dec 28 '14 at 08:17
 - 
                    1http://stackoverflow.com/questions/1453538/how-to-redirect-the-output-of-dbms-output-put-line-to-a-file – simplify_life Dec 28 '14 at 11:00
 - 
                    What kind of program are you calling the procedure from? If it isn't something that supports this natively. e.g. via `set serveroutput on`, you'd need to extract the buffered output - it's stored in a buffer as the docs say, not saved in a table. ([This is one way](http://stackoverflow.com/a/19143017/266304), but it really depends on your client and what you want to do next). – Alex Poole Dec 28 '14 at 18:11
 - 
                    Worse stuff man is that you could have easily find the answer, just by typing your question on the internet. – Andy K Dec 29 '14 at 08:14
 
3 Answers
2
            
            
        You need use SET SERVEROUTPUT ON
set serveroutput on
begin
dbms_output.put_line('something to write')
end;
        starko
        
- 1,150
 - 11
 - 26
 
1
            As already said you'll have to include a SET SERVEROUTPUT ON; statement before  your DECLARE but you'll also need to handle the output on the OS level:
sqlplus -s user/pword@db '@script.sql;' > log.txt
Hint: the -s flag will hide the sqlplus version info from your log file.
        mmmmmpie
        
- 2,908
 - 1
 - 18
 - 26