DB Access Module for Sybase User’s Guide : Chapter 2 Technical Information : BulkReader and BulkInserter
BulkReader and BulkInserter
The DB Access Module for Sybase supports bulk reading through the array interface provided by the Sybase Open Client Client-Library function, ct_bind(). Bulk writing is supported through the array interface provided by the Sybase Bulk-Library function, blk_bind(), which is part of the Sybase Open Client/Open Server common libraries.
Using an RWDBBulkInserter
The RWDBBulkInserter functions execute() and execute(size_t iters) cause values that are associated with each of the arrays shifted into self to be inserted into the table associated with self. The following example uses an RWDBBulkInserter to insert an array of strings and integers into a table.
 
// Define the arrays that will hold the data to be inserted
size_t length = 10;
RWDBTBuffer<RWCString> stringBuffer(length);
RWDBTBuffer<int> intBuffer(length);
 
// Populate the arrays using a user-defined function
setValues(stringBuffer, intBuffer);
 
// Define the inserter.
RWDBBulkInserter ins = table.bulkInserter(connection);
 
// Shift the arrays into the inserter
ins << stringBuffer << intBuffer;
 
// Insert up to length values at a time
RWDBResult result = ins.execute(length);
 
// The results of the insertion will now be visible to the
// reader
RWDBReader rdr = table.reader(connection);