Creating User Exits
The following instructions help you to create user exits on Windows and UNIX systems. For more information about the parameters and functions that are described in these instructions, see Reference for Oracle GoldenGate for Windows and UNIX.
Note:
User exits are case-sensitive for database object names. Names are returned exactly as they are defined in the hosting database. Object names must be fully qualified.
To Create User Exits
-
In C code, create either a shared object (UNIX systems) or a DLL (Windows) and create or export a routine to be called from Extract or Replicat. This routine is the communication point between Oracle GoldenGate and your routines. Name the routine whatever you want. The routine must accept the following Oracle GoldenGate user exit parameters:
-
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. This function enables you to use theEXITPARAM
option of theTABLE
orMAP
statement to pass a parameter that is a literal string to the user exit. This is only valid during the exit call to process a specific record. This function also enables you to pass parameters specified with thePARAMS
option of theCUSEREXIT
parameter at the exit call startup.
-
-
In the source code, include the
usrdecs.h
file. Theusrdecs.h
file is the include file for the user exit API. It contains type definitions, return status values, callback function codes, and a number of other definitions. Theusrdecs.h
file is installed within the Oracle GoldenGate directory. Do not modify this file. -
Include Oracle GoldenGate callback routines in the user exit when applicable. Callback routines retrieve record and application context information, and they modify the contents of data records. To implement a callback routine, use the
ERCALLBACK
function in the shared object. The user callback routine behaves differently based on the function code that is passed to the callback routine.ERCALLBACK (
function_code
,buffer
,result_code
);Where:
-
function_code
is the function to be executed by the callback routine. -
buffer
is a void pointer to a buffer containing a predefined structure associated with the specified function code. -
result_code
is the status of the function that is executed by the callback routine. The result code that is returned by the callback routine indicates whether or not the callback function was successful. -
On Windows systems, Extract and Replicat export the
ERCALLBACK
function that is to be called from the user exit routine. The user exit must explicitly load the callback function at run-time using the appropriate Windows API calls.
-
-
Include the
CUSEREXIT
parameter in your Extract or Replicat parameter file. This parameter accepts the name of the shared object or DLL and the name of the exported routine that is to be called from Extract or Replicat. You can specify the full path of the shared object or DLL or let the operating system's standard search strategy locate the shared object.CUSEREXIT {
DLL
|shared_object
}routine
[, INCLUDEUPDATEBEFORES] [, PARAMS 'startup_string
']Where:
-
DLL
is a Windows DLL andshared_object
is a UNIX shared object that contains the user exit function. -
INCLUDEUPDATEBEFORES
gets before images forUPDATE
operations. -
PARAMS
'startup_string'
supplies a startup string, such as a startup parameter.
-
Example 9-42 Example of Base Syntax, UNIX
CUSEREXIT eruserexit.so MyUserExit
Example 9-43 Example Base Syntax, Windows
CUSEREXIT eruserexit.dll MyUserExit