Provides the caller with the ability to extract certain log records from the DB2 Common Server database logs, and to query the Log Manager for current log state information. This API can only be used on databases with recoverable database logs (the configuration parameters LOGRETAIN or USEREXIT enabled).
Authorization
One of the following:
Required Connection
Database
Version
sqlutil.h
C API Syntax
/* File: sqlutil.h */ /* API: Asynchronous Read Log */ /* ... */ SQL_API_RC SQL_API_FN sqlurlog ( sqluint32 CallerAction, SQLU_LSN * pStartLsn, SQLU_LSN * pEndLsn, char * pLogBuffer, sqluint32 LogBufferSize, SQLU_RLOG_INFO * pReadLogInfo, struct sqlca * pSqlca); /* ... */ |
API Parameters
Sample Programs
Usage Notes
If the requested action is to read the log, the caller will provide a log sequence number range and a buffer to hold the log records. The ASYNCHRONOUS READ LOG API reads the log sequentially, bounded by the requested LSN range, and returns log records associated with tables having the DATA CAPTURE option CHANGES, and an SQLU_RLOG_INFO structure with the current active log information. If the requested action is query, the API returns an SQLU_RLOG_INFO structure with the current active log information.
To use the Asynchronous Log Reader, first query the database log for a valid starting LSN. Following the query call, the read log information structure (SQLU-RLOG-INFO) will contain a valid starting LSN (in the initialLSN member), to be used on a read call. The end of the current active log will be in the curActiveLSN member of the read log information structure. The value used as the ending LSN on a read can be one of the following:
For more information about the read log information structure, see SQLU-RLOG-INFO.
The propagatable log records read within the starting and ending LSN range are returned in the log buffer. A log record does not contain its LSN, it is contained in the buffer before the actual log record. Descriptions of the various DB2 Common Server log records returned by sqlurlog can be found in Appendix F, DB2 Common Server Log Records.
After the initial read, in order to read the next sequential log record, add 1 to the last read LSN returned in SQLU-RLOG-INFO. Resubmit the call, with this new starting LSN and a valid ending LSN. The next block of records is then read. An sqlca code of SQLU_RLOG_READ_TO_CURRENT means the log reader has read to the end of the current active log.