-
Spool file in pl/sql ?
Hello!
How I can create a SPOOL file (e.g test.txt) in pl/sql on server. I know in SQL*PLUS, but I have no idea in pl/sql.
Can some one write a simple pl/sql example in which using sql query and then generate spool file.
Thanks in advance.
-
Check the usage of package UTL_FILE.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
happened to have one handy - this works for 9i only
CREATE DIRECTORY test_dir AS 'c:\temp';
CREATE OR REPLACE PROCEDURE test
AS
v_output_file1 utl_file.file_type;
BEGIN
/* Ensure TEST_DIR below is in all caps */
/* Third argument below is W which overwrites file each time, change to A to append */
v_output_file1 := utl_file.fopen('TEST_DIR', 'my_test.csv', 'W');
FOR cursor_emp IN (SELECT empnom,ename, deptno FROM emp)
LOOP
utl_file.put_line(v_output_file1, cursor_emp.empno || ',' || cursor_emp.ename || ',' || cursor_emp.deptno);
END LOOP;
utl_file.fclose_all;
END;
/
I'm stmontgo and I approve of this message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|