Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: exporting ASCII file from Oracle8
I guess it would help if I include the code.
The attached Stored Procedure file will allow you to export data to an ASCII file.
Modify the cursor to select only the columns that you want to export. The v_sep variable can be set to whatever field delimiter you want. Change the TEXT_IO.FOPEN filemode to 'a' for appending.
PROCEDURE ClassExp IS
out_file TEXT_IO.FILE_TYPE;
v_outbuf VARCHAR2(3200);
v_outfile VARCHAR2(100) := 'c:\windows\desktop\aecclass.dat';
CURSOR class_cursor IS SELECT * FROM class;
BEGIN
out_file := TEXT_IO.FOPEN(v_outfile, 'w');
FOR class_record IN class_cursor LOOP v_outbuf := to_char(class_record.class_id) || v_sepEND LOOP;
|| to_char(class_record.parent) || v_sep
|| class_record.class_name;
TEXT_IO.PUT_LINE(out_file, v_outbuf);
TEXT_IO.PUT_LINE('Closing the file...'); TEXT_IO.FCLOSE(out_file);