DBMS_LOB Interface

This section describes the programs available through the DBMS_LOB packages in several categories.

Working with BFILEs

The following sections describe the programs in the DBMS_LOB package that perform operations on BFILE objects.

The DBMS_LOB.FILEEXISTS function

The FILEEXISTS function indicates whether the given BFILE locator points to a file that exists in the operating system. Here’s the specification for this program:

FUNCTION DBMS_LOB.FILEEXISTS
   ( file_loc IN BFILE )
   RETURN INTEGER;

The file_loc parameter is the name of the file locator. The function returns one of the following values:

Value

Description

0

The specified file does not exist

1

The specified file exists

Exceptions

One of the following exceptions may be raised if the file_loc parameter contains an improper value (e.g., NULL):

DBMS_LOB.NOEXIST_DIRECTORY
 DBMS_LOB.NOPRIV_DIRECTORY
 DBMS_LOB.INVALID_DIRECTORY

Restrictions

The FILEEXISTS function asserts a purity level with the RESTRICT_REFERENCES pragma.

PRAGMA RESTRICT_REFERENCES (fileexists, WNDS, RNDS, WNPS, RNPS);

Examples

This block uses the FILEEXISTS function to see if chapter01.txt exists in the BOOK_TEXT directory:

DECLARE book_file_loc BFILE := NULL; book_file_exists BOOLEAN := FALSE; BEGIN book_file_loc := BFILENAME( 'BOOK_TEXT', 'chapter01.txt' ); book_file_exists := DBMS_LOB.FILEEXISTS( book_file_loc ) = 1; IF book_file_exists THEN DBMS_OUTPUT.PUT_LINE ('chapter01.txt exists in BOOK_TEXT directory'); ELSE DBMS_OUTPUT.PUT_LINE ('chapter01.txt ...

Get Oracle Built-in Packages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.