Inside the SRV_BULK event handler

Inside the SRV_BULK event handler, the application must respond to the bulk request that triggered the handler. However, its response depends on which type of bulk request the client issued. The application retrieves the request type by calling srv_thread_props with cmd set to CS_GET and property set to SRV_T_BULKTYPE.

If the request type is SRV_TEXTLOAD, SRV_IMAGELOAD, or SRV_UNITEXTLOAD, the application reads the text or image data from the client in chunks, using the srv_text_info and srv_get_text routines. For details, see the “Text and Image” topics page in the Open Server Server-Library/C Reference Manual.

If the request type is SRV_BULKLOAD, the application processes the bulk-copy rows using a combination of client-side and server-side routines. To process the bulk-copy rows, the SRV_BULK event handler should:

  1. Call blk_rowalloc to allocate a CS_BLK_ROW structure.

    The CS_BLK_ROW structure is a hidden structure that holds formatted bulk-copy rows sent from the client.

  2. Call blk_getrow to retrieve the formatted row from the client. This call retrieves all column data except columns of type text, image, sensitivity, or boundary. The gateway can process these later. If the row contains text, image, sensitivity, or boundary data, blk_getrow returns CS_BLK_HASTEXT. Otherwise, it returns CS_SUCCEED. If there are no more rows, the bulk-copy operation is complete and blk_getrow returns CS_END_DATA.

  3. If the gateway must examine the row content (for example, to route rows to particular remote servers or reject data), it calls blk_colval to examine the value of each column in the bulk row.

  4. Call the client-side routine blk_sendrow to send the formatted rows to the remote server.

  5. If an incoming bulk row contains text, image, sensitivity, or boundary data, the server portion of the gateway calls blk_gettext to retrieve the row’s text, image, sensitivity, or boundary portion. The handler calls the client-side routine blk_sendtext to send it on to the remote server.

  6. Call blk_rowdrop to deallocate the CS_BLK_ROW structure allocated by blk_rowalloc.

  7. Call the client-side routine blk_done to indicate that the batch or bulk-copy operation is complete.

  8. Call blk_drop to deallocate the bulk-descriptor structure.