O'Reilly logo

Oracle Built-in Packages by John Beresniewicz, Charles Dye, Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required