BFILENAME Function in Oracle SQL – PLSQL

The BFILENAME function in Oracle SQL / PLSQL is used to get a BFILE locator for a LOB file at a physical location.

Syntax for the BFILENAME function in Oracle SQL / PLSQL is:

SELECT BFILENAME(‘directory’, ‘file_name’)
FROM table_name;

  • directory is the folder / directory object which serves as an alias name for the full path where the file is placed on the file server.
  • file_name is the name of the file on the server.

Example:

First we need to create a directory say ‘sampleDir’ that will point to the a location say ‘/sample/files/techhoney’ location on the server as follows:

CREATE DIRECTORY sampleDir as '/sample/files/techhoney';

Now we can use the ‘sampleDir’ directory object in the BFILENAME function as shown below:

SELECT BFILENAME('sampleDir','report.pdf')
FROM dual;

Tagged , , , , , , , , , , , . Bookmark the permalink.