Skip Headers

Oracle C++ Call Interface Programmer's Guide
Release 2 (9.2)

Part Number A96583-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

OCCI Classes and Methods, 2 of 22


Bfile Class

The Bfile class defines the common properties of objects of type BFILE. A BFILE is a large binary file stored in an operating system file outside of the Oracle database. A Bfile object contains a logical pointer to a BFILE, not the BFILE itself.

Methods of the Bfile class enable you to perform specific tasks related to Bfile objects.

Methods of the ResultSet and Statement classes, such as getBfile() and setBfile(), enable you to access a SQL BFILE value.

To create a null Bfile object, use the syntax:

Bfile(); 

The only methods valid on a null Bfile object are setNull(), isNull(), and operator=().

To create an uninitialized Bfile object, use the syntax:

Bfile(const Connection *connectionp);

An uninitialized Bfile object can be initialized by:

To create a copy of an existing Bfile object, use the syntax:

Bfile(const Bfile &srcBfile);

Summary of Bfile Methods

Table 8-2 Bfile Methods  
Method Summary

close()

Close a previously opened BFILE.

closeStream()

Close the stream obtained from the BFILE.

fileExists()

Test whether the BFILE exists.

getDirAlias()

Return the directory alias of the BFILE.

getFileName()

Return the name of the BFILE.

getStream()

Return data from the BFILE as a Stream object.

isInitialized()

Test whether the Bfile object is initialized.

isNull()

Test whether the Bfile object is atomically null.

isOpen()

Test whether the BFILE is open.

length()

Return the number of bytes in the BFILE.

open()

Open the BFILE with read-only access.

operator=()

Assign a BFILE locator to the Bfile object.

operator==()

Test whether two Bfile objects are equal.

operator!=()

Test whether two Bfile objects are not equal.

read()

Read a specified portion of the BFILE into a buffer.

setName()

Set the directory alias and file name of the BFILE.

setNull()

Set the Bfile object to atomically null.

close()

This method closes a previously opened BFILE.

Syntax
void close();

closeStream()

This method closes the stream obtained from the BFILE.

Syntax
void closeStream(Stream *stream); 
Parameters
stream

The stream to be closed.

fileExists()

This method tests whether the BFILE exists. If the BFILE exists, then true is returned; otherwise, false is returned.

Syntax
bool fileExists() const;

getDirAlias()

This method returns a string containing the directory alias associated with the BFILE.

Syntax
string getDirAlias() const;

getFileName()

This method returns a string containing the file name associated with the BFILE.

Syntax
string getFileName() const;

getStream()

This method returns a Stream object read from the BFILE. If a stream is already open, it is disallowed to open another stream on the Bfile object. The stream must be closed before performing any Bfile object operations.

Syntax
Stream* getStream(unsigned int offset = 1,
   unsigned int amount = 0);
Parameters
offset

The starting position at which to begin reading data from the BFILE. If offset is not specified, the data is written from the beginning of the BLOB.

Valid values are:

Numbers greater than or equal to 1.

amount

The total number of bytes to be read from the BFILE; if amount is 0, the data will be read in a streamed mode from input offset until the end of the BFILE.

isInitialized()

This method tests whether the Bfile object has been initialized. If the Bfile object has been initialized, then true is returned; otherwise, false is returned.

Syntax
bool isInitialized() const;

isNull()

This method tests whether the Bfile object is atomically null. If the Bfile object is atomically null, then true is returned; otherwise, false is returned.

Syntax
bool isNull() const;

isOpen()

This method tests whether the BFILE is open. The BFILE is considered to be open only if it was opened by a call on this Bfile object. (A different Bfile object could have opened this file as more than one open can be performed on the same file by associating the file with different Bfile objects). If the BFILE is open, then true is returned; otherwise, false is returned.

Syntax
bool isOpen() const;

length()

This method returns the number of bytes (inclusive of the end of file marker) in the BFILE.

Syntax
unsigned int length() const;

open()

This method opens an existing BFILE for read-only access. This function is meaningful the first time it is called for a Bfile object.

Syntax
void open();

operator=()

This method assigns a Bfile object to the current Bfile object. The source Bfile object is assigned to this Bfile object only when this Bfile object gets stored in the database.

Syntax
Bfile& operator=(const Bfile &srcBfile);
Parameters
srcBfile

The Bfile object to be assigned to the current Bfile object.

operator==()

This method compares two Bfile objects for equality. The Bfile objects are equal if they both refer to the same BFILE. If the Bfile objects are null, then false is returned. If the Bfile objects are equal, then true is returned; otherwise, false is returned.

Syntax
bool operator==(const Bfile &srcBfile) const;
Parameters
srcBfile

The Bfile object to be compared with the current Bfile object.

operator!=()

This method compares two Bfile objects for inequality. The Bfile objects are equal if they both refer to the same BFILE. If the Bfile objects are not equal, then true is returned; otherwise, false is returned.

Syntax
bool operator!=(const Bfile &srcBfile) const;
Parameters
srcBfile

The Bfile object to be compared with the current Bfile object.

read()

This method reads a part or all of the BFILE into the buffer specified, and returns the number of bytes read.

Syntax
unsigned int read(unsigned int amt,
   unsigned char *buffer,
   unsigned int bufsize,
   unsigned int offset = 1) const;
Parameters
amt

The number of bytes to be read.

Valid values are:

Numbers greater than or equal to 1.

buffer

The buffer that the BFILE data is to be read into.

Valid values are:

A number greater than or equal to amt.

bufsize

The size of the buffer that the BFILE data is to be read into.

Valid values are:

A number greater than or equal to amt.

offset

The starting position at which to begin reading data from the BFILE. If offset is not specified, the data is written from the beginning of the BFILE.

setName()

This method sets the directory alias and file name of the BFILE.

Syntax
void setName(const string &dirAlias,
   const string &fileName);
Parameters
dirAlias

The directory alias to be associated with the BFILE.

fileName

The file name to be associated with the BFILE.

setNull()

This method sets the Bfile object to atomically null.

Syntax
void setNull();


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2001, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback