blk_rowxfer

Description

Transfers one or more rows during a bulk-copy operation without specifying or receiving a row count.

Syntax

CS_RETCODE blk_rowxfer(blkdesc)
 
 CS_BLKDESC       *blkdesc;

Parameters

blkdesc

A pointer to the CS_BLKDESC that is serving as a control block for the bulk-copy operation. blk_alloc allocates a CS_BLKDESC structure.

Returns

blk_rowxfer returns:

Table 4-7: blk_rowxfer return values

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_PENDING

Asynchronous network I/O is in effect. For more information, see the “Asynchronous Programming” topics page in the Open Client Client-Library/C Reference Manual.

CS_BLK_HAS_TEXT

The row contains one or more columns which have been marked for transfer using blk_textxfer.

The application must call blk_textxfer to transfer data for these columns before calling blk_rowxfer to transfer the next row.

CS_END_DATA

When copying data out from a database, blk_rowxfer returns CS_END_DATA to indicate that all rows have been transferred.

When copying data into a database, blk_rowxfer does not return CS_END_DATA.

CS_ROW_FAIL

A recoverable error occurred while fetching a row.

Applies to bulk-copy-out operations only.

Recoverable errors include memory allocation failures and conversion errors (such as overflowing the destination buffer) that occur while copying row values to program variables. In the case of buffer-overflow errors, blk_rowxfer sets the corresponding *indicator variable(s) to a value greater than 0. Indicator variables must have been specified in the application’s calls to blk_bind.

When blk_rowxfer returns CS_ROW_FAIL, the application must continue calling blk_rowxfer to keep retrieving rows, or it can call ct_cancel to cancel the remaining results.

Examples

Example 1

/*
 ** BulkCopyIn()
 ** BLKDATA and DATA_END are defined in the bulk copy
 ** example program.
 */
 
 CS_STATIC CS_RETCODE 
 BulkCopyIn(connection)
 CS_CONNECTION   *connection;
 {
     CS_BLKDESC *blkdesc;
     CS_DATAFMT datafmt;/* variable descriptions */
     Blk_Data *dptr;/* data for transfer */
     CS_INTdatalen[5];/* variable data length */
     CS_INT len;
     CS_INT numrows;
    /*
     ** Ready to start the bulk copy in now that all the
     ** connections have been made and have a table name.
     ** Start by getting the bulk descriptor initializing.
     */
     ...CODE DELETED.....
    /*
     ** Now to bind the variables to the columns and
     ** transfer the data
     */
     datafmt.locale = 0;
     datafmt.count = 1;
     dptr = BLKDATA;
     while (dptr->pub_id != DATA_END)
     {
         datafmt.datatype = CS_INT_TYPE;
         datafmt.maxlength = sizeof(CS_INT);
         datalen[0] = CS_UNUSED;
        if (blk_bind(blkdesc, 1, &datafmt, &dptr->pub_id, 
             &datalen[0], NULL) != CS_SUCCEED)
         {
             ex_error("BulkCopyIn: blk_bind(1) failed");
             return CS_FAIL;
         }
         datafmt.datatype = CS_CHAR_TYPE;
         datafmt.maxlength = MAX_PUBNAME - 1;
         datalen[1] = strlen(dptr->pub_name);
         if (blk_bind(blkdesc, 2, &datafmt, dptr->pub_name,
              &datalen[1], NULL) != CS_SUCCEED)
         {
             ex_error("BulkCopyIn: blk_bind(2) failed");
             return CS_FAIL;
         }
         datafmt.maxlength = MAX_PUBCITY - 1;
         datalen[2] = strlen(dptr->pub_city);
         if (blk_bind(blkdesc, 3, &datafmt, dptr->pub_city,
              &datalen[2], NULL) != CS_SUCCEED)
         {
             ex_error("BulkCopyIn: blk_bind(3) failed");
             return CS_FAIL;
         }
         datafmt.maxlength = MAX_PUBST - 1;
         datalen[3] = strlen(dptr->pub_st);
         if (blk_bind(blkdesc, 4, &datafmt, dptr->pub_st,
              &datalen[3], NULL) != CS_SUCCEED)
         {
             ex_error("BulkCopyIn: blk_bind(4) failed");
             return CS_FAIL;
         }
         datafmt.maxlength = MAX_BIO - 1;
         datalen[4] = strlen((char *)dptr->pub_bio);
         if (blk_bind(blkdesc, 5, &datafmt, dptr->pub_bio,
              &datalen[4], NULL) != CS_SUCCEED)
         {
             ex_error("BulkCopyIn: blk_bind(5) failed");
             return CS_FAIL;
         }
         if (blk_rowxfer (blkdesc) == CS_FAIL)
         {
             ex_error("BulkCopyIn: blk_rowxfer() failed");
             return CS_FAIL;
         }
         dptr++;
     }
 
     /* ALL the rows sent so clear up */
     ...CODE DELETED.....
 
     return CS_SUCCEED;
 }

Usage

See also

blk_bind, blk_rowxfer_mult, blk_textxfer