In Oracle, BFILENAME Function returns a BFILE locator that is linked with a physical LOB file on the server file system. Below is an example to store a file into a table using BFILENAME in Oracle.

Syntax

BFILENAME function takes two arguments, first is the directory object name and second is the file name.

BFILENAME (directory_object, file_name)

BFILENAME Function Example

In the following example, we will create a table emp_resume and a directory object to store resume file using the BFILE data type and then will insert a record using BFILENAME function.

    1. Create a Table and a Directory Object
    Create Table emp_resume (Empno NUMBER, resume BFILE)
    /
    
    Create or Replace Directory MY_DOC as 'C:\Docs'
    /
    1. Insert a record into the table using BFILENAME function
    INSERT INTO emp_resume (empno, resume) 
    VALUES (7399, BFILENAME ('MY_DOC', '7369_Resume.doc'));

Output

1 row created.

See also:

Leave a Reply