Creating Macro Libraries
You can create a macro library that contains one or more macros. By using a macro library, you can define a macro once and then use it within many parameter files.
To Create a Macro Library
-
Open a new file in a text editor.
-
Use commented lines to describe the library, if needed.
-
Using the syntax described in Defining a Macro, enter the syntax for each macro.
-
Save the file in the
dirprm
sub-directory of the Oracle GoldenGate directory as:filename.mac
Where:
filename
is the name of the file. The.mac
extension defines the file as a macro library.
The following sample library named datelib
contains two macros, #make_date
and #assign_date
.
-- datelib macro library -- 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; MACRO #assign_date PARAMS (#target_col, #year, #month, #day) BEGIN #target_col = #make_date (#year, #month, #day) END;
To use a macro library, use the INCLUDE
parameter at the beginning of a parameter file, as shown in the following sample Replicat parameter file.
INCLUDE /ggs/dirprm/datelib.mac REPLICAT rep ASSUMETARGETDEFS USERIDALIAS ogg MAP fin.acct_tab, TARGET fin.account;
When including a long macro library in a parameter file, you can use the NOLIST
parameter to suppress the listing of each macro in the Extract or Replicat report file. Listing can be turned on and off by placing the LIST
and NOLIST
parameters anywhere within the parameter file or within the macro library file. In the following example, NOLIST
suppresses the listing of each macro in the hugelib
macro library. Specifying LIST
after the INCLUDE
statement restores normal listing to the report file.
NOLIST INCLUDE /ggs/dirprm/hugelib.mac LIST INCLUDE /ggs/dirprm/mdatelib.mac REPLICAT REP