|
Class CBatchParam<T> Overview template<class
TParamBase=CParamBase> CBatchParam<T> is a template wrapper for executing multiple sets of parameterized SQL statements or stored procedures by a single call. If a provider supports interface ICommandPrepare, the passed strSQL of CBatchParam<T>::Open is prepared. If an OLEDB provider supports multiple parameter sets, A CBatchParam<T> object truly sends multiple sets of parameter data into its data source. If it doesn't, the module calls ICommand::Execute inside repeatedly until all the sets of parameter data are sent. For details, see the source codes of CBatchParam<T>::DoBatch. The big advantage of use of this template over rowset is speed. Use of this template avoids retrieving data to a client for update and delete. Further more, it also reduces network traffic by packing multiple sets of parameter data together. Additionally, it eliminate parsing a statement repeatedly. If a parameterized statement or stored procedure is involved with BLOBs or output parameters, you may need to call CBatchParam<T>::EnableBatch to disable batch update mode because most of OLEDB providers are not capable for such a case. It is very simple and convenient to send multiple sets of data into a data source. For how to use the class, see example MultiProcs. To use it correctly, you must tell what data type and parameter type each of parameters is, when opening a CBatchParam<T> object. For each of parameters of variable-length data types such as DBTYPE_STR, DBTYPE_WSTR and DBTYPE_BYTES only, you may suggest a max buffer length in bytes. If not, CBatchParam<T> uses default sizes of buffers. For all the other cases, buffer lengths are ignored. CBatchParam<T> automatically copy all the returned data from a stored procedure into buffers allocated by calling codes if available. |