Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: File generation thro Oracle

    Can you create a physical file (.txt or .csv) from within Oracle?

  2. #2
    Join Date
    Jan 2004
    Location
    Hyderabad, India
    Posts
    37
    Hi

    You can refer to the metalink note 119644.1 for this purpose.

    Here i am pasting the code for your reference...

    CREATE OR REPLACE PROCEDURE write_file AS
    id UTL_FILE.FILE_TYPE;
    name VARCHAR2(20) := 'my_file';
    err VARCHAR2(100);
    num NUMBER;
    BEGIN
    id := UTL_FILE.FOPEN('/u05/home/tsupport/asoracco/utl_file',name, 'w');
    IF UTL_FILE.IS_OPEN(id)
    THEN
    DBMS_OUTPUT.PUT_LINE('Opened');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Still Closed');
    END IF;
    UTL_FILE.PUT_LINE(id,name); UTL_FILE.PUT(id,'It worked and wrote to this file'); UTL_FILE.FCLOSE(id);
    DBMS_OUTPUT.PUT_LINE('Successful write to file'); EXCEPTION
    WHEN OTHERS THEN
    err := SQLERRM;
    num := SQLCODE;
    DBMS_OUTPUT.PUT_LINE(err); DBMS_OUTPUT.PUT_LINE(num);
    DBMS_OUTPUT.PUT_LINE('Error in writing to file');
    END;
    Regards
    Suneel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •