Re: exporting ASCII file from Oracle8

From: Dale Leonard <dll_at_mindspring.com>
Date: 1998/05/28
Message-ID: <6klco0$6e5$1_at_camel0.mindspring.com>#1/1


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';

  • v_sep is set to be a tab. v_sep VARCHAR2(10) := ' ';
     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_sep

|| to_char(class_record.parent) || v_sep
|| class_record.class_name;
TEXT_IO.PUT_LINE(out_file, v_outbuf);
    END LOOP;
    TEXT_IO.FCLOSE(out_file);
EXCEPTION
    WHEN OTHERS THEN
        TEXT_IO.PUT_LINE('Closing the file...');
        TEXT_IO.FCLOSE(out_file);

END; Dale
dll_at_mindspring.com Received on Thu May 28 1998 - 00:00:00 CEST

Original text of this message