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:
1 | CREATE DIRECTORY sampleDir as '/sample/files/techhoney' ; |
Now we can use the ‘sampleDir’ directory object in the BFILENAME function as shown below:
1 | SELECT BFILENAME( 'sampleDir' , 'report.pdf' ) |
2 | FROM dual; |