Base class for user-defined callback methods that fetch and send character data.
More...
#include <rw/db/datacb.h>
RWDBCharCallback is a base class for user-defined callback methods for character data. Derive from this class to implement the callback methods to send and retrieve data.
- Example
- Please see the example in the entry for RWDBDataCallback.
◆ RWDBCharCallback() [1/2]
RWDBCharCallback::RWDBCharCallback |
( |
size_t | entries = 1 | ) |
|
|
inline |
Constructs an RWDBCharCallback with entries entries. If entries is more than one, array binding is in effect. Please see the DB Interface Module User's Guide chapter "Bulk/Array Input", in the section "Using the Open SQL Classes", for more information.
◆ RWDBCharCallback() [2/2]
◆ ~RWDBCharCallback()
virtual RWDBCharCallback::~RWDBCharCallback |
( |
| ) |
|
|
inlinevirtual |
◆ onFetch()
virtual bool RWDBCharCallback::onFetch |
( |
size_t | rownum, |
|
|
const char * | theData, |
|
|
size_t | byteLength, |
|
|
RWDBNullIndicator | ni, |
|
|
bool & | lastPiece ) |
|
pure virtual |
When data callback classes are bound to a SQL statement and RWDBOSql::fetch() is called to fetch the results, this method is invoked to receive the data.
- Parameters
-
rownum | The row in the current rowset this data is from (0-based indexing). Each call to RWDBOSql::fetch() retrieves the next rowset from the result set of the SQL statement execution. This method is invoked by the Access Module as many times as needed for each row in the rowset. |
theData | A pointer to an array containing the fetched data. The contents of theData are undefined if ni is true. |
byteLength | The length in bytes of the data in theData, if any. |
ni | The null indicator parameter. true if the fetched value is null, false otherwise. |
lastPiece | true if this is the last piece of data for this value, otherwise it is false . This parameter can be set to true by the callee to stop fetching data for this row's value and to move to the next row. |
- Returns
- Return
false
or throw an exception from this method to stop fetching data and terminate the operation, otherwise return true
to continue.
◆ onSend()
virtual bool RWDBCharCallback::onSend |
( |
size_t | rownum, |
|
|
char * | theData, |
|
|
size_t & | byteLength, |
|
|
RWDBNullIndicator & | ni, |
|
|
bool & | lastPiece ) |
|
pure virtual |
When data callback classes are bound to a SQL statement and RWDBOSql::execute() is called to execute the statement, this method is invoked as needed to supply the data to send to the database. Note that the method RWDBDataCallback::getLength() may need to be be implemented in the derived class to send data to the database.
- Parameters
-
rownum | The row for which data is needed (0-based indexing). This will always be 0 unless array binding is used. Array binding is in effect when the callback is constructed with entries greater than 1. Please see the DB Interface Module User's Guide chapter "Bulk/Array
Input", in the section "Using the Open SQL Classes", for more information. |
theData | A pointer to an array where the callee should put the data to be sent. If ni is true this parameter is ignored. |
byteLength | The size of theData in bytes and should be set by the callee to the length in bytes written to theData. If ni is true this parameter is ignored. |
ni | Set this to true to indicate that a null value is being sent to the database. If ni is true , theData, lastPiece, and byteLength are ignored. |
lastPiece | When the last piece of data for rownum is being supplied this must be set to true . This parameter is ignored if ni is true . |
- Returns
- Return
false
or throw an exception to stop sending data and terminate the operation, otherwise return true
.
◆ operator=()