Creating a BFILE locator
BFILE locators are trivial to create; you simply invoke the BFILENAME function and pass it a directory alias and a filename. Unlike locators for other LOB types, you don't need to store a BFILE locator in the database prior to using it. In the following example we create a BFILE locator for the HTML file containing the Tannery Falls web page. We then store that locator into the waterfalls table.
DECLARE web_page BFILE;BEGIN --Delete row for Tannery Falls so this example can --be executed multiple times DELETE FROM waterfalls WHERE falls_name='Tannery Falls'; --Invoke BFILENAME to create a BFILE locator web_page := BFILENAME('BFILE_DATA','Tannery Falls.htm'); --Save our new locator in the waterfalls table INSERT INTO waterfalls (falls_name, falls_web_page) VALUES ('Tannery Falls',web_page);END;A BFILE locator is simply a combination of directory alias and filename. The actual file and directory don't even need to exist. That is, Oracle allows you to create directory aliases for directories that do not yet exist, and BFILENAME allows you to create BFILE locators for files that do not yet exist. There are times when it's convenient to do these things.
|