Public Methods | |
Lob () | |
Lob (OCISvcCtx *svcctx, OCILobLocator *lob_desc, OCIError *err, int type, int cache_mode) | |
void | init (OCISvcCtx *svcctx, OCILobLocator *lob_desc, OCIError *err, int type, int cache_mode) |
void | init (OCIEnv *env, OCISvcCtx *svcctx, OCIError *err) |
~Lob () | |
void | drop () |
void | seek (unsigned offset, int dir) |
unsigned | tell () |
unsigned | read (void *buff, int blen) |
unsigned | write (const void *buff, int blen) |
void | trunc (unsigned new_len) |
void | loadFromBFile (BFile &bfile, unsigned int amount, unsigned int dst_offset, unsigned int src_offset) |
void | setCacheMode (int mode) |
unsigned | getLen () const |
void | copyFrom (Lob &src_lob, unsigned amount, unsigned dst_off, unsigned src_off) |
void | copyFrom (BFile &src_file, unsigned amount, unsigned dst_off, unsigned src_off) |
void | copyFrom (TLob &src_file, unsigned amount, unsigned dst_off, unsigned src_off) |
Friends | |
class | TLob |
class | Cursor |
A brief example for interaction with a lob. Lets assume, there is a table IMAGES created already (e.g. by issuing the command "create table IMAGES ( KEY integer, IMAGE blob )". Of course, a storage class should be included, so that the large object(s) can be stored appropriately. After that, you may write (with an initialized pointer con to a Connection-object):
using namespace OCICPP; con->execUpdate( "insert into IMAGES (KEY,IMAGE) values ( 42, EMPTY_BLOB())" ); Cursor cur; con->execQuery( "select * from IMAGES where KEY=42 for update", cur ); Lob lob; cur.fetch(); cur.getBLOB( "IMAGE", lob ); lob.write( "something", 9 ); cur.drop();
In detail, a new row is inserted into the IMAGES table (identified by 42
). The table, as mentioned above, stores an integer column as well as a binary large object (BLOB) column.
For those of you familiar with Oracle Servers, it may not be an insight that the column IMAGE is initialized with an empty BLOB (by specifying EMPTY_BLOB()/EMPTY_CLOB() as the content of this column). It would be a mistake to leave this content out of the insert statement, since the a NULL-value would be inserted and a NULL-LOB may not be used for reading from or writing to.
Afterwards, the newly inserted column is being selected for update, which is mandatory, if a value from this column is to be modified while the cursor points to it. The Lob-instance lob is being initilized from the Cursor's current column IMAGE and afterwards 'something' is written into this BLOB. Alternatively, a real image or some other binary data may be stored there.
|
Create an unbound large object. This object may be used to be initialized from a Cursor's BLOB / CLOB column, e.g.. |
|
Destruct a reference to a large object. |
|
Copies data from a temporary Lob src_lob
|
|
Copies data from a BFile src_file
|
|
Copies data from Lob src_lob Both locators must be of the same type (they are both must be BLOB or CLOB) Lob cache must not be enabled for either locator. The amount parameter indicates the maximum amount to copy. If the end of the source LOB is reached before the specified amount is copied, the operation terminates without error.
|
|
Free a previously initalized large object. A lob freed in this manner may be reused afterwards.
|
|
Retreive the total amount of data stored within this lob. |
|
Load/copy all or a portion of the file into an internal LOB. No character set conversions are performed when copying the FILE data to a CLOB/NCLOB. If the destination's start position is beyond the end of the current data, zero-byte fillers (for BLOBs) or spaces (for CLOBs) are written into the destination LOB from the end of the data to the beginning of the newly written data from the source. The destination LOB is extended to accommodate the newly written data if it extends beyond the current length of the destination LOB. It is an error to extend the destination LOB beyond the maximum length allowed (4 gigabytes) The amount parameter indicates the maximum amount to load. If the end of the source FILE is reached before the specified amount is loaded,the operation terminates without error. |
|
Read a sequence of buf_len bytes from the lob into the buffer buf. The amount of bytes actually transfered is being returned. |
|
Set the position for reading/writing within a large object.
|
|
|
|
Retuns the current position from the start of the lob. For this position, the inequation 0 <= tell() < getLen() holds. |
|
Truncates the lob to a specified to a length of new_len bytes. The function throws an exception if new_len is greater than the current LOB's length. |
|
Write a sequence of buf_len bytes into the lob from the buffer buf. The amount of bytes actually transfered is being returned. |