1.102 MACRO
Valid For
Extract and Replicat
Description
Use the MACRO
parameter to create an Oracle GoldenGate macro. See Administering Oracle GoldenGate for more information about using macros, including how to invoke them properly.
Default
None
Syntax
The following must be used in the order shown:
MACRO#macro_name
PARAMS (#param_name
[, ...]) BEGIN macro_body END;
-
MACRO
-
Starts the macro specification.
-
#
-
The macro character. Macro and parameter names must begin with a macro character. Anything in the parameter file that begins with the macro character is assumed to be either a macro or a macro parameter.
The default macro character is the pound (#) character, as in the following examples:
MACRO #macro1 PARAMS (#param1, #param2)
You can change the macro character with the
MACROCHAR
parameter. -
macro_name
-
The name of the macro. Macro names must be one word with alphanumeric characters (underscores are allowed) and are not case-sensitive. Each macro name in a parameter file must be unique. Do not use quotes, or else the macro name will be treated as text and ignored.
-
PARAMS
-
Starts a parameter clause. A parameters clause is optional. The maximum size and number of parameters is unlimited, assuming sufficient memory is available.
-
param_name
-
Describes a parameter to the macro. Parameter names are not case-sensitive. Do not use quotes, or else the parameter name will be treated as text and ignored.
Every parameter used in a macro must be declared in the
PARAMS
statement, and when the macro is invoked, the invocation must include a value for each parameter. -
BEGIN
-
Begins the macro body. Must be specified before the macro body.
-
macro_body
-
The body of the macro. The size of the macro body is unlimited, assuming sufficient available memory. A macro body can include any of the following types of statements:
-
Simple parameter statements, as in:
COL1 = COL2
-
Complex statements, as in:
COL1 = #val2
-
Invocations of other macros, as in:
#colmap(COL1, #sourcecol)
-
-
END;
-
Concludes the macro definition. The semicolon is required to complete the definition.
Examples
- Example 1
-
The following example defines a macro that takes parameters.
MACRO #make_date PARAMS (#year, #month, #day) BEGIN @DATE('YYYY-MM-DD', 'CC', @IF(#year < 50, 20, 19), 'YY', #year, 'MM', #month, 'DD', #day) END;
- Example 2
-
The following example defines a macro that does not require parameters.
MACRO #option_defaults BEGIN GETINSERTS GETUPDATES GETDELETES INSERTDELETES END;
- Example 3
-
The following example defines a macro named
#assign_date
that calls another macro named#make_date
.MACRO #assign_date PARAMS (#target_col, #year, #month, #day) BEGIN #target_col = #make_date (#year, #month, #day) END;
Parent topic: Oracle GoldenGate Parameters