title: Oracle - Create text file using stored procedure
body: <p>Need help on creating text file using stored procedure in oracle 10. I'm very new to this so please guide me from the start.</p>
  
  <p>I found code and created it as stored procedure. I run it and it is VALID. But I executed it, I got error of <code>"INVALID FILE NAME... AT SYS.UTL_FILE..."</code></p>
  
  <p>I first created a directory that grants read, write on directory.</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE refcursorkim IS
     l_file      utl_file.file_type;
     l_file_name VARCHAR2(60);
  BEGIN
  l_file := utl_file.fopen('UTL_DIR', l_file_name, 'w');          
     SELECT 'KY' || TO_CHAR(SYSDATE, 'yyyymmdd') || '1.txt' INTO l_file_name  FROM dual;
     utl_file.putf(l_file,l_file_name);
     utl_file.fclose(l_file);
  END refcursorkim;
  </code></pre>
  
  <p>I don't know what I'm missing, since I'm not familiar to this at all. Another thing, is the file automatically being created in the directory specified?</p>
  
  <p>Hope you could help me. Thank you and God bless!</p>