title: ORA-22285: non-existent directory or file for FILEOPEN operation
body: <p>I am trying to insert code of XML file into a column which is of XMLtype</p>
  
  <p>I have below query which is working fine</p>
  
  <pre><code>select extract(xmlcol,'/*') 
     from (SELECT xmltype(BFILENAME('MEDIA_DIR', 'xmldata1.xml'),nls_charset_id('UTF-8')) xmlcol FROM dual)
  </code></pre>
  
  <p>On running this query I am getting the Xmlcode inside the xml file(xmldata1) in one row.</p>
  
  <p>Now, As per my requirement I have created a type which reads data from the XMLfile.
  Below is the code of member function of the type:</p>
  
  <pre><code>create or replace type body t_emp
  as
  
      member function get_xml return xmltype is
      v_xml xmltype;
      begin
      select extract(xmlcol,'/*') into v_xml
         from (SELECT xmltype(BFILENAME('MEDIA_DIR', 'xmldata1.xml'),nls_charset_id('UTF-8')) xmlcol FROM dual);
      return v_xml;
      end get_xml;
  end;
  </code></pre>
  
  <p>I am calling this type member function in my code. Below is the code </p>
  
  <pre><code>declare
  t_emp1 t_emp; 
  r1 xmltype;
  begin
  t_emp1 := t_emp(2);
  r1 := t_emp1.get_xml;
  insert into EMPLOYEE_XML values (t_emp1.id,r1);
  end;
  </code></pre>
  
  <p>Here variable <strong>r1</strong> is of importance as I am fetching XML data in this variable.
  On running this code I am getting below error:</p>
  
  <pre><code>ORA-22285: non-existent directory or file for FILEOPEN operation
  </code></pre>
  
  <p>I am not able to understand why this error is coming as the directory exist. I am able to run previously mentioned SQL query.</p>
  
  <p>Thanks!!</p>