This chapter describes the Oracle GoldenGate user exit functions and their syntax and includes the following topics:
For more information about using Oracle GoldenGate user exits, see Administering Oracle GoldenGate for Windows and UNIX.
Write the user exit routine in C programming code. Use the CUSEREXIT parameter to call the user exit from a Windows DLL or UNIX shared object at a defined exit point within Oracle GoldenGate processing. Your user exit routine must be able to accept different events and information from the Extract and Replicat processes, process the information as desired, and return a response and information to the caller (the Oracle GoldenGate process that called it). For more information and syntax for the CUSEREXIT parameter, see "CUSEREXIT".
| Parameter | Description |
|---|---|
EXIT_CALL_TYPE |
Indicates when, during processing, the routine is called. |
EXIT_CALL_RESULT |
Provides a response to the routine. |
EXIT_PARAMS |
Supplies information to the routine. |
ERCALLBACK |
Implements a callback routine. Callback routines retrieve record and Oracle GoldenGate context information, and they modify the contents of data records. |
Use EXIT_CALL_TYPE to indicate when, during processing, the Extract or Replicat process (the caller) calls a user exit routine. A process can call a routine with the following calls.
| Call type | Processing point |
|---|---|
|
|
Valid when the |
|
|
Called just before either of the following:
|
|
|
Called just before an Extract or Replicat checkpoint is written. |
|
|
Called during Extract processing before an ASCII input record is written to the discard file. The associated ASCII buffer can be retrieved and manipulated by the user exit using callback routines. This call type is not applicable for use with the Replicat process. |
|
|
Called during Replicat processing before a record is written to the discard file. Records can be discarded for several reasons, such as when a value in the Oracle GoldenGate change record is different from the current version in the target table.The associated discard buffer can be retrieved and manipulated by the user exit using callback routines. This call type is not applicable for use with the Extract process. |
|
|
Called just after either of the following:
|
|
|
Called during Extract or Replicat processing just before Oracle GoldenGate terminates after a fatal error. |
|
|
Called during Replicat processing when a marker from a NonStop server is read from the trail, and before writing to the marker history file. |
|
|
This call is the basis of most user exit processing. When When a user exit is used for a data-pump Extract that is configured in |
|
|
Called at the start of processing. The user exit can perform initialization work, such as opening files and initializing variables. |
|
|
Called before the process stops gracefully or ends abnormally. The user exit can perform completion work, such as closing files or outputting totals. |
|
|
Set by the user exit routines to instruct the caller how to respond when each exit call completes. |
Use EXIT_CALL_RESULT to provide a response to the routine.
| Call result | Description |
|---|---|
|
|
Instructs the caller to terminate immediately. |
|
|
Rejects records for further processing. |
|
|
If the routine does nothing to respond to an event,
... and |
|
|
Instructs Extract or Replicat to skip the record, but update the statistics that are printed to the report file for that table and for that operation type. |
|
|
Instructs the caller to stop processing gracefully. |
Use EXIT_PARAMS to supply information to the user exit routine, such as the program name and user-defined parameters. You can process a single data record multiple times.
| Exit parameter | Description |
|---|---|
|
|
Specifies the full path and name of the calling process, for example |
|
|
|
|
|
Set on return from an exit. For database records, determines whether Extract or Replicat processes the record again. This allows the user exit to output many records per record processed by Extract, a common function when converting Enscribe to SQL (data normalization). To request the same record again, set |
Use ERCALLBACK to execute a callback routine. A user callback routine retrieves context information from the Extract or Replicat process and sets context values, including the record itself, when the call type is one of the following:
EXIT_CALL_PROCESS_RECORD
EXIT_CALL_DISCARD_RECORD
EXIT_CALL_DISCARD_ASCII_RECORD
ERCALLBACK (function_code, buffer, result_code );
function_codeThe function to be executed by the callback routine. The user callback routine behaves differently based on the function code passed to the callback routine. While some functions can be used for both Extract and Replicat, the validity of the function in one process or the other is dependent on the input parameters that are set for that function during the callback routine. See Section 6.7, "Function Codes" for a full description of available function codes.
bufferA void pointer to a buffer containing a predefined structure associated with the specified function code.
result_codeThe status of the function executed by the callback routine. The result code returned by the callback routine indicates whether or not the callback function was successful. A result code can be one of the values in Table 6-4.
| Code | Description |
|---|---|
|
|
Invalid data was encountered when retrieving or setting column data. |
|
|
A date, timestamp, or interval type |
|
|
A numeric type of column contains an invalid numeric value. |
|
|
The column was not found in a compressed update record (update by a database that only logs the values that were changed). |
|
|
The specified environment value could not be found in the record. |
|
|
The metadata could not be retrieved because the name of the table or column did not fit in the allocated buffer. |
|
|
The record could not be fetched. View the error message to see the reason. |
|
|
An internal error occurred when processing the DDL record. The record is probably incomplete. |
|
|
An invalid callback function code was passed to the callback routine. |
|
|
A non-existent column was referred to in the function call. |
|
|
The routine is trying to manipulate a data type that is not supported by Oracle GoldenGate for that purpose. |
|
|
The callback function was called at an improper time. |
|
|
An invalid parameter was passed to the callback function. |
|
|
The source database instance could not be found. |
|
|
The target database instance could not be found. |
|
|
This function is not supported for this process. |
|
|
The callback function succeeded. |
|
|
A |
|
|
An invalid table name was specified. |
|
|
The specified user token could not be found in the record. |
Function codes determine the output of the callback routine. The callback routine expects the contents of the data buffer to match the structure of the specified function code. The callback routine function codes and their data buffers are described in the following sections. The following is a summary of available functions.
Table 6-5 Summary of Oracle GoldenGate Function Codes
| Function code | Description |
|---|---|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Returns the fully qualified two- or three-part name of a table or other object that is associated with the record that is being processed. |
|
|
Returns the unqualified name of a table or other object that is associated with the record that is being processed. |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |