SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWDBCharCallback Class Referenceabstract

Base class for user-defined callback methods that fetch and send character data. More...

#include <rw/db/datacb.h>

Inheritance diagram for RWDBCharCallback:
RWDBDataCallback

Public Member Functions

 RWDBCharCallback (size_t entries=1)
 
 RWDBCharCallback (const RWDBCharCallback &cb)
 
virtual ~RWDBCharCallback ()
 
virtual bool onFetch (size_t rownum, const char *theData, size_t byteLength, RWDBNullIndicator ni, bool &lastPiece)=0
 
virtual bool onSend (size_t rownum, char *theData, size_t &byteLength, RWDBNullIndicator &ni, bool &lastPiece)=0
 
RWDBCharCallbackoperator= (const RWDBCharCallback &cb)
 
- Public Member Functions inherited from RWDBDataCallback
size_t entries () const
 
virtual size_t getLength (size_t rownum) const
 

Detailed Description

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.

Constructor & Destructor Documentation

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::RWDBCharCallback ( const RWDBCharCallback cb)
inline

Copy constructor.

virtual RWDBCharCallback::~RWDBCharCallback ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

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
rownumThe 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.
theDataA pointer to an array containing the fetched data. The contents of theData are undefined if ni is true.
byteLengthThe length in bytes of the data in theData, if any.
niThe null indicator parameter. true if the fetched value is null, false otherwise.
lastPiecetrue 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.
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
rownumThe 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.
theDataA pointer to an array where the callee should put the data to be sent. If ni is true this parameter is ignored.
byteLengthThe 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.
niSet 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.
lastPieceWhen 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.
RWDBCharCallback& RWDBCharCallback::operator= ( const RWDBCharCallback cb)
inline

Assignment operator.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.