DBMS_OUTPUT on UTL_FILE [message #411627] |
Mon, 06 July 2009 02:32  |
manns
Messages: 59 Registered: March 2006 Location: Bangalore
|
Member |

|
|
Hi,
I have Package and wich is having many procedure and function with dbms_output debug messages to execute.
I want to read this messages in UTL file without changing my package(dbms_output). How can i achive this??
thanks & regatds
Manju
|
|
|
|
Re: DBMS_OUTPUT on UTL_FILE [message #411743 is a reply to message #411627] |
Mon, 06 July 2009 09:12   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
manns wrote on Mon, 06 July 2009 09:32 | Hi,
I have Package and wich is having many procedure and function with dbms_output debug messages to execute.
|
Make sure you only actually execute these dbms_output commands if a debug switch is set. Otherwise you might run into an overflow error in production.
|
|
|
Re: DBMS_OUTPUT on UTL_FILE [message #411770 is a reply to message #411743] |
Mon, 06 July 2009 11:52   |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
I don't understand the question. Do you mean you want to get the content of DBMS_OUTPUT buffer and write it to file?
SQL> set serveroutput on
SQL> DECLARE
2 v_file UTL_FILE.file_type;
3 v_line VARCHAR2 (200);
4 v_status NUMBER;
5 n NUMBER := 1;
6 BEGIN
7 DBMS_OUTPUT.ENABLE (1000000);
8 DBMS_OUTPUT.PUT_LINE('this is first test line');
9 DBMS_OUTPUT.PUT_LINE('this is last test line');
10 v_file := UTL_FILE.fopen ('MY_DIR', 'test.txt', 'w');
11 LOOP
12 DBMS_OUTPUT.get_line (v_line, v_status);
13 IF v_status = 0
14 THEN
15 UTL_FILE.put_line (v_file, n||'-->'||v_line);
16 n := n + 1;
17 ELSE
18 EXIT;
19 END IF;
20 END LOOP;
21 UTL_FILE.fclose (v_file);
22
23 DBMS_OUTPUT.PUT_LINE('this final line is left in buffer');
24 END;
25 /
this final line is left in buffer
PL/SQL procedure successfully completed.
SQL>
Now, test.txt contains:
1-->this is first test line
2-->this is last test line
|
|
|
|