Using ERCALLBACK
ERCALLBACK
is the basic user exit function for Oracle GoldenGate. It is used to pull the record context into user exit. It's like a package that contains multiple individual functions inside it. You can call these functions and get return values. For example, functions such as GET_BEFORE_AFTER_IND
, or GET_COLUMN_VALUE_FROM_NAME
can be called. These functions are called function_code
.
Syntax
ERCALLBACK (function_code, buffer, result_code );
-
function_code
-
The 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 Function Codes for a full description of available function codes.
-
buffer
-
A void pointer to a buffer containing a predefined structure associated with the specified function code.
-
result_code
-
The 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 4-4.
Table 4-4 Result Codes
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. |
You can use ERCALLBACK
to perform many different function calls. For example, if you want to get the name of a table, you can use the following command:
ERCALLBACK (GET_TABLE_NAME, &var, &result_code)
c
code for the user exit to perform any of the calls for functions provided in the section Function Codes. With the combination of the different function_code
calls, you can perform many tasks using ERCALLBACK
, such as:
- Recreate DML statements
- Perform transformations
- Pull specific columns out of a record
- Write information to a report file
For example, if you need a message written to the report file each time the lag in the heartbeat table exceeds a certain threshold, you could use the CUSEREXIT
function. The CUSEREXIT
function would then make numerous calls to ERCALLBACK
to get the lag column data, perform calculations and the comparison, and if the lag is over the specified threshold then write a message to the report file.