Macro no Goldengate

Main Article
A Macro Library is a collection of OGG Macros used to externalize OGG parameters shared across multiple Groups. The library can be a single file containing multiple Macro definitions, or multiple files. Best practice is to create a directory “dirmac” as part of the OGG installation environment to hold the library files. Another best practice is to use the suffix “.mac” on all library files. This way Macro Library files can be recognized without having to open and read one.
Using these best practice tips, the following Macro Library would be stored inside of the file “$OGG_BASE/dirmac/macrolib.mac”.

MACRO #dbconnect BEGIN userid gguser, password AACAAAAAAAAAAAHAAIFBOIYAMCGIMARE, encryptkey default END;
MACRO #bpsettings BEGIN -- The following are "best practice" runtime options which may be -- used for workload accounting and load balancing purposes. -- STATOPTIONS RESETREPORTSTATS ensures that process -- statistics counters will be reset whenever a new report file is -- created. STATOPTIONS RESETREPORTSTATS
-- Generate a report every day at 1 minute after midnight. -- This report will contain the number of operations, by operation -- type, performed on each table. REPORT AT 00:01
-- Close the current report file and create a new one daily at 1 -- minute after midnight. Eleven report files are maintained on disk -- in the dirrpt directory/folder for each GoldenGate group. The -- current report file names are <group name>.rpt. The older reports -- are <group name>0.rpt through <group name>9.rpt, with the -- older report files having larger numbers. REPORTROLLOVER AT 00:01
-- REPORTCOUNT denotes that every 60 seconds the Replicat report file -- in the dirrpt directory/folder will have a line added to it that reports the -- total number of records processed since startup, along with the rated -- number of records processed per second since startup, and the change -- in rate, or "delta" since the last report. -- In a production environment, this setting would typically be 1 hour. REPORTCOUNT EVERY 60 SECONDS, RATE
-- End of "best practices" section END;
MACRO #funcsmap PARAMS (#src_table, #target_table) BEGIN    -- Map the source table provided in the variable #src_table to the target    -- table listed in the variable #target_table. There are extra columns in the    -- target we need to populate, so get the data from either the environment    -- variable, or the user token data sent over from Extract    MAP #src_table, TARGET #target_table,     colmap (usedefaults,             orders_trans_ts = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),             trans_rec_loc8tr = @STRCAT (@GETENV ("RECORD", "FILESEQNO"),                                         @GETENV ("RECORD", "FILERBA")),             extract_lag_ms = @TOKEN ("TKN-EXTLAG-MSEC"),             replicat_lag_ms = @GETENV ("LAG", "MSEC"),             src_db_name = @TOKEN ("TKN-SRC-DBNAME"),             src_db_version = @TOKEN ("TKN-SRC-DBVERSION"),             src_txn_csn = @TOKEN ("TKN-TXN-CSN")      ); END;
Macros are identified by the keyword “Macro” followed by the macro name “#<name>”. The Macro body is contained within the “BEGIN” and “END” statements. The three Macros provided in this example library file are #dbconnect, #bpsettings, and #funcsmap.
    The #dbconnect Macro provides a centralized location for storing database connection information. The database login password is Blowfish encrypted using the “DEFAULT” GoldenGate encryption key.     #bpsettings activates best practices settings for generating hourly and daily activity counts.     #funcsmap accepts input parameters and uses them to build a Replicat map statement.
Using the Macro Library
Consider the following Replicat parameter file:
nolist include ./dirmac/macrolib.mac list
replicat rfuncb #dbconnect () #bpsettings () sourcedefs ./dirdef/mydefs.defs discardfile ./dirrpt/rfuncb.dsc, purge #funcsmap (amer.orders, euro.funcs_test)
IMPORTANTE--->  If list is not included in the parameter file after using nolist, no information will be written to the Group report file.

Sobre Alexandre Pires

ORACLE OCS Goldengate Specialist, OCE RAC 10g R2, OCP 12C, 11g, 10g , 9i e 8i - Mais de 25 anos de experiência na área de TI. Participei de projetos na G&P alocado na TOK STOK, EDINFOR alocado na TV CIDADE "NET", 3CON Alocado no PÃO DE AÇUCAR, DISCOVER alocado na VIVO, BANCO IBI e TIVIT, SPC BRASIL, UOLDIVEO alocado no CARREFOUR e atualmente na ORACLE ACS atendendo os seguintes projetos: VIVO, CLARO, TIM, CIELO, CAIXA SEGUROS, MAPFRE, PORTO SEGURO, SULAMERICA, BRADESCO SEGUROS, BANCO BRADESCO, BASA, SANTANDER, CNJ, TSE, ELETROPAULO, EDP, SKY, NATURA, ODEBRESHT, NISSEI, SICREDI, CELEPAR, TAM, TIVIT, IBM, SMILES, CELEPAR, SERPRO,OKI,BANCO PAN, etc
Esse post foi publicado em GOLDENGATE e marcado , , , , , , , . Guardar link permanente.

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do

Você está comentando utilizando sua conta Sair /  Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s