How to Read DBFS Contents Using PLSQL (Doc ID 1378785.1)

Last updated on AUGUST 06, 2012

Applies to:

Oracle Server - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.
Oracle RDBMS, Exadata that has Database Filesystem.


Symptoms

Executing a PLSQL procedure or anonymous block to read the contents of a file from a DBFS mount fails with the following error:


DECLARE
  buf raw(32767);
  props dbms_dbfs_content.properties_t;
  data blob;
  itype integer;
  len number;
  off number;
  amt number;
BEGIN
  dbms_dbfs_content.getpath(path=>'/dbfs_direct/FS1/test', properties=> props, content=>data,  
    item_type=> itype, prop_flags=>dbms_dbfs_content.prop_data);
  len := dbms_lob.getlength(data);
  dbms_output.put_line('Length: ' || len);
  off := 1;
  while off < len loop
      amt := 32767;
      dbms_lob.read(data, amt, off, buf);
      if amt > 0 then
        dbms_output.put_line(utl_raw.cast_to_varchar2(buf));
      end if;
      off := off + amt;
  end loop;
  dbms_output.put_line('');
END;
/

*
ERROR at line 1:
ORA-64002: specified path is invalid
ORA-06512: at "SYS.DBMS_DBFS_CONTENT", line 455
ORA-01403: no data found
ORA-06512: at "SYS.DBMS_DBFS_CONTENT", line 3103
ORA-06512: at "SYS.DBMS_DBFS_CONTENT", line 3162
ORA-06512: at line 10

Changes

Utilization of DBFS mounts for storing files.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms