Previous Table of Contents Next


This procedure allows you to copy RAW data into a LOB. Like COPY, the new data overwrites the existing data. If the offset is past the end of the destination LOB, the difference is padded with 0 byte spaces.

The following routines are applicable to BFILEs only.


FUNCTION FILEEXISTS(

     file_loc IN BFILE)

RETURN INTEGER;

Use this function to confirm the existence of the BFILE as specified by the file locator passed in file_loc. This function returns a 1 if the file exists, and a 0 if it does not. A NULL is returned if an operating system error occurs or there are insufficient privileges to the file system.


PROCEDURE FILEGETNAME(

     file_loc IN BFILE,

     dir_alias OUT VARCHAR2,

     filename OUT VARCHAR2);

file_loc Locator of the BFILE.
dir_alias Name of the DIRECTORY object.
filename Returned name of the BFILE.

This procedure retrieves the name of the file identified by the file locator passed in file_loc. The dir_alias is the name of the DIRECTORY object created with the CREATE DIRECTORY statement. This is a new type of object in Oracle8, designed to hold the operating system path of files such as those associated with BFILE data.


FUNCTION FILEISOPEN(

     file_loc IN BFILE)

RETURN INTEGER;

This function can be used to determine if the file identified by the file locator passed in file_loc is open or not. A 1 is returned if the file is opened with the given file locator, and a 0 is passed if it is not. Only the status of the passed locator is checked, so the file could still be opened by way of another file locator even if a 0 is returned.


PROCEDURE FILEOPEN(

     file_loc IN OUT BFILE,

     open_mode IN BINARY_INTEGER DEFAULT FILE_READONLY);

FILEOPEN opens the specified BFILE in read-only mode. Oracle does not support writing of BFILEs, but the presence of the open_mode parameter suggests that it will in the future.


PROCEDURE LOADFROMFILE(

     dest_lob or dest_file IN OUT BLOB, CLOB, NCLOB or BFILE,

     src_lob IN BFILE,

     amount IN INTEGER,

     dest_offset IN INTEGER DEFAULT 1,

     src_offset IN INTEGER DEFAULT 1);

dest_lob Locator for BLOB, CLOB, or NCLOB to be written to.
src_lob Locator of BFILE to get data from.
amount Number of bytes to copy into the dest_lob.
dest_offset Offset in bytes or characters to start writing to the destination LOB.
src_offset Offset in bytes to start reading data from the source BFILE.

Use this procedure to copy data from a BFILE into another LOB. If the dest_offset exceeds the length of the destination LOB, the difference is padded with spaces. If the dest_offset is less than the total length of the destination LOB, the existing data is overwritten by the new data. No check is performed to verify that character sets match when loading CLOB or NCLOB data.


PROCEDURE FILECLOSE(

     file_loc IN OUT BFILE);

This procedure closes the file specified with file_loc.


PROCEDURE FILECLOSEALL;

This procedure closes all files currently open by the current session.

The following is a brief example of how DBMS_LOB works. The first listing creates the objects needed for the demo.


DROP TABLE lobs;

CREATE TABLE lobs (

    id NUMBER PRIMARY KEY,

    clobs CLOB,

    blobs BLOB,

    bfiles BFILE

    );



REM We have already created a file here called test.log during the

UTL_FILE demo.

REM We’ll use the same file as a BFILE in the DBMS_LOB demo.



DROP DIRECTORY bfile_dir;

CREATE DIRECTORY bfile_dir AS '/u01/app/oracle/logs’;


Previous Table of Contents Next
Используются технологии uCoz