Defining a Macro
To define an Oracle GoldenGate macro, use the MACRO
parameter in the parameter file. MACRO
defines any input parameters that are needed and it defines the work that the macro performs.
Syntax
MACRO #macro_name
PARAMS (#p1
, #p2
[, ...]) BEGINmacro_body
END;
Table 8-12 Macro Definition Arguments
Argument | Description |
---|---|
MACRO |
Required. Indicates the start of an Oracle GoldenGate macro definition. |
# |
The name of the macro. Macro and parameter names must begin with a macro character. The default macro character is the pound (#) character, as in A macro or parameter name can be one word consisting of letters and numbers, or both. Special characters, such as the underscore character ( To avoid parsing errors, the macro character cannot be used as the first character of a macro name. For example, Macro and parameter names are not case-sensitive. Macro or parameter names within quotation marks are ignored. |
PARAMS (# |
Optional definition of input parameters. Specify a comma-separated list of parameter names and enclose it within parentheses. Each parameter must be referenced in the macro body where you want input values to be substituted. You can list each parameter on a separate line to improve readability (making certain to use the open and close parentheses to enclose the parameter list). See Calling a Macro that Contains Parameters for more information. |
BEGIN |
Begins the macro body. Must be specified before the macro body. |
|
The macro body. The body is a syntax statement that defines the function that is to be performed by the macro. A macro body can include any of the following types of statements.
|
END; |
Ends the macro definition. The semicolon is required to complete the definition. |
The following is an example of a macro definition that includes parameters. In this case, the macro simplifies the task of object and column mapping by supplying the base syntax of the MAP
statement with input parameters that resolve to the names of the owners, the tables, and the KEYCOLS
columns.
MACRO #macro1 PARAMS ( #o, #t, #k ) BEGIN MAP #o.#t, TARGET #o.#t, KEYCOLS (#k), COLMAP (USEDEFAULTS); END;
The following is an example of a macro that does not define parameters. It executes a frequently used set of parameters.
MACRO #option_defaults BEGIN GETINSERTS GETUPDATES GETDELETES INSERTDELETES END;