Restarting data capture

You can restart data capture where the last data capture session ended.

Before you begin

The restart position is the sequence number of a CDC record that was returned in the previous data capture session. You can use the sequence number of the last CDC record processed in the previous data capture session. However, to preserve transactional integrity, you should determine last transaction for which a commit or rollback operation was not processed and restart capture at the beginning of that transaction. In this case, the restart position is the lowest sequence number of the CDC_REC_BEGINTX records for incomplete transactions. To avoid reprocessing already committed transactions, you should also determine the largest sequence number of the CDC_REC_COMMTX record that you have already processed in a previous data capture session.

About this task

To restart data capture:

Procedure

  1. Determine the restart position.
    To preserve transactional integrity:
    1. Find all captured transactions that did not return a CDC_REC_COMMTX or CDC_REC_RBTX record.
    2. Compare the sequence numbers of the CDC_REC_BEGINTX records for the incomplete transactions. The lowest sequence number is the restart position.
  2. Open a new capture session by running the cdc_opensess() function.
  3. Run the cdc_startcapture() function for the table on which you want to restart capturing data.
  4. Active the session by running the cdc_activatesess() function. Pass the appropriate sequence number as the position argument.
    Data capture restarts for the table at the last transaction that was processed.
  5. Discard any transactions whose CDC_REC_COMMTX sequence number is less than that of the CDC_REC_COMMTX record with the largest sequence number that you processed in the previous data capture session.