A Summary of the Open SQL Classes
As mentioned previously, the Open SQL interface contains three classes: RWDBOSql, RWDBTBuffer<T>, and RWDBMultiRow. Here is a brief overview of how these classes work:
*RWDBOSql
Class RWDBOSql encapsulates an SQL statement. The class provides facilities for:
*binding both input and output buffers to the statement
*executing the statement
*fetching the results of the statement into the output buffers that are bound to the statement
The SQL statement may be passed in as an RWCString when the RWDBOSql is constructed, or provided later in the application. RWDBTBuffers, each representing input data or output storage, can be bound to the RWDBOSql after construction.
*RWDBTBuffer<T>
Class RWDBTBuffer<T> is a template class that encapsulates storage for a single element or for an array of elements of type Type, the template argument. The length of the array is set in the appropriate constructor. Alternatively, the RWDBTBuffer can create this array and manage its associated memory for you.
Along with the data array, RWDBTBuffer holds an array of null indicators. Null indicators are single values, each corresponding to a single element in your array, which indicate whether the value is NULL. An RWDBTBuffer can be used to bind an input parameter to an SQL statement, or a buffer to a result column.
*RWDBMultiRow
Class RWDBMultiRow allows RWDBTBuffer instances, which typically represent either a single field or a column of data, to form a collection. RWDBMultiRow provides row operations on this collection, such as extracting a single row from the collection into an RWDBRow object, and producing an RWDBSchema from metadata of the collection.
In addition, RWDBMultiRow can automatically construct an RWDBTBuffer of appropriate type from an RWDBSchema; RWDBMultiRow uses the information from each column of the RWDBSchema to create a matching RWDBTBuffer. These features make RWDBMultiRow a perfect fit when integrating code written for Open SQL with code written for the existing API.
These classes are base classes that define interfaces for specifying data callback methods, which support working with very large data. The derived custom classes implement their virtual methods onFetch() and onSend(), and if necessary getLength(). The send and fetch methods are then called repeatedly during database execution, taking advantage of a database’s “data-at-execution” feature in which large data can be sent in pieces.
Note that some database vendors do not support data-at-execution, in which case this feature is not available in the relevant access module.
For complete technical descriptions of these classes and their functions, please consult the SourcePro API Reference Guide.