A typical application follows these steps to perform a bulk-copy-out operation:
Calls ct_con_props to set the required properties to open the connection.
Calls ct_connect to open the connection.
Calls blk_alloc to allocate a bulk-descriptor structure.
For each column of interest, the application:
(Optional) Calls blk_describe to retrieve a column’s description. This step is necessary if an application lacks information about a column’s datatype or size.
(Optional) Calls blk_bind to bind a program variable to the source column. If the data for a column will be transferred via blk_textxfer, call blk_bind with *buffer as NULL.
Columns can be bound either to scalar variables or to arrays. When columns are bound to scalar variables, each call to blk_rowxfer_mult transfers column values for a single row into the bound variables into the database. For array binding, an array is bound to each column, and multiple column values are transferred into each array by each call to blk_rowxfer_mult.
The discussion in this chapter assumes that array binding is not used. See blk_bind in Chapter 4, “Bulk-Library Routines”
Transfers the data by calling blk_rowxfer_mult in a loop:
The application calls blk_rowxfer_mult repeatedly to transfer each row to program variables until blk_rowxfer_mult returns CS_END_DATA.
If the row contains columns whose data is transferred in chunks, the application calls blk_textxfer in a loop for each column. Data being transferred via blk_textxfer must reside at the end of the row, following any bound columns.
For example, suppose an application bulk-copies columns 1, 3, 5, 7, and 9 and must call blk_textxfer to copy columns 7 and 9. The application calls blk_bind once for each column, passing buffer as NULL for columns 7 and 9. After calling blk_rowxfer_mult to transfer a row from the table, the application must call blk_textxfer in a loop to copy the data for column 7 and then call blk_textxfer in another loop to copy the data for column 9.
Calls blk_done(CS_BLK_ALL) to indicate that the bulk-copy operation is complete.
Calls blk_drop to deallocate the bulk-descriptor structure.
An application can call blk_bind between calls to blk_rowxfer_mult to specify
different program variable address or length.