Results 1 to 4 of 4

Thread: utl_file

  1. #1
    Join Date
    Mar 2003
    Posts
    45

    Unanswered: utl_file

    Hi,

    My System is a Windows 2000 stand-alone with Oracle8i installed. I am the Oracle Admin in this system and have granted all the system privileges necessary to administer the database.

    I am trying to output the result of a simple SQL query into a *.txt file on my local C:\temp drive. While I get “PL/SQL successfully completed.” when I go the c:\temp directory, I do not see the *.txt file.

    Here are my settings and the anonymous pl/sql:

    init.ora

    utl_file_dir = “c:\temp”

    the Database was restarted after puting the line above


    SQL> create directory utl_file_dir as 'c:\temp';
    Directory created.

    SQL> grant write, read on directory utl_file_dir to scott;
    Grant succeeded.


    declare
    emp UTL_FILE.FILE_TYPE;
    begin
    emp:= utl_file.fopen( 'c:\temp', 'test.txt', 'W' );
    FOR emp IN (SELECT emp_name FROM employees)
    LOOP
    utl_file.put_line( emp.emp_name );
    END LOOP;
    utl_file.fclose(emp);
    end;
    /

    SQL> declare
    2 emp UTL_FILE.FILE_TYPE;
    3 begin
    4 emp:= utl_file.fopen( 'c:\temp', 'test.txt', 'W' );
    5 FOR emp IN (SELECT emp_name FROM employees)
    6 LOOP
    7 utl_file.put_line( emp.emp_name );
    8 END LOOP;
    9 utl_file.fclose(emp);
    10 end;
    11 /
    PL/SQL successfully completed.


    I then go to my c:\temp directory to look for the test.txt file and I can ‘t find it. I click on refresh and still nothing. I did system wide search and still nothing. What am I doing wrong here??

  2. #2
    Join Date
    Oct 2002
    Location
    greenwich.ct.us
    Posts
    279
    UTL_FILE_DIR is on the server, not the client.

  3. #3
    Join Date
    Mar 2003
    Posts
    45

    Utl_file

    The server and the client are one and the same. That is my home pc is the a stand-alone with Oracle8i installed on it.

  4. #4
    Join Date
    Jan 2003
    Location
    Woking
    Posts
    107

    Re: Utl_file

    Originally posted by alexxx15
    The server and the client are one and the same. That is my home pc is the a stand-alone with Oracle8i installed on it.
    Hi,
    I dont know if that is the reason, but too many variables with
    the same name (emp).
    your file pointer is also called emp and cursor index is also emp.
    why dont you change one of them.
    say why not try.

    for i in (select ename from emp)

    Hope it helps.
    nn

Posting Permissions

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