Use second-pass replication
- Last Updated: August 8, 2023
- 4 minute read
- OpenEdge Pro2
- Version 6.5
- Documentation
Second pass replication can be used in two ways: to perform data warehouse auditing tasks or to replicate to a first pass and second pass target database.
Set up second-pass replication as audit
Second-pass replication creates a copy of the source table in the
second-pass database and, inserts a record into this table each time there is a
change in the source table (for UPDATE, DELETE, INSERT).
A new record is created in the target (or staging) table every time
there is a change in the table, regardless of whether the change happens to the same
field. The replicated table holds a new record for every change in the source table.
A new property, SECOND_PASS, is added to the predefs.i file. This property supports second-pass
replication and the default value of this parameter is set to NO. To start Second Pass Replication for a setup, this
property should be set to YES for that specific
setup.
To set up second-pass replication:
- Create a copy of the Pro2 setup directory and rename it, appending it with
SecondPass. For example, if your setup is in the folder Pro2, copy paste that folder and rename it to Pro2_SecondPass.Note: Copy all folders from the Pro2 setup directory to the SecondPass folder except for thedbandPro2Web(PAS Instance)folders. - Create a new folder named db in the newly created SecondPass folder. This db folder is created for the SecondPass target database.
- Open a Proenv window and enter
cd C:\Pro2_SecondPass\dbto navigate to thedbfolder, for example,cd C:\Pro2_SecondPass\db - Create an empty target database from the Proenv window. Enter
prodb target database name empty, for example,prodb secondtgt empty. - Start the target database from the Proenv window. Enter
proserve target database name -S port numberfor example,proserve secondtgt -S 6677. - Load the schema generated from first pass into the target database. In the
Proenv window enter
prowin target database name, for example,prowin secondtgt.The Procedure Editor window appears.
- Navigate to .
The Data Administration window appears.
- Navigate to .
The Load Data Definitions window appears.
- Select the schema file as the input file, for example,
Sports-tgt.df. Click OK.A success message appears after the load is complete.
- Navigate to
C:\Pro2 second pass folder\bprepl\Scriptsfolder, for example,C:\Pro2_SecondPass\bprepl\Scripts. - Right-click the Pro2 - Editor tool
and select Properties.
The Pro2 - Editor Properties window appears.
- On the Shortcut tab, edit the Start in field to reflect the Pro2 second
pass folder, for example,
C:\Pro2_SecondPass.Note: You can use the same steps for therunbulkloaderutility if the you need to do second pass bulk load. - Edit the Pro2_env.bat file to set the
value of the Pro2 setup location to the
C:\Pro2_SecondPassdirectory. - Open the
replProc.pffile from C:/Pro2_SecondPass/bprepl/scripts folder and ensure that the rep and Pro2 database section to point to the first pass setup. - Save the contents of the
replProc.pffile. - Edit your database's
.pffile, and modify the target databases section to point to the database in the SecondPass directory. Save the contents of the.pffile. For example:
Note: If you use a Microsoft SQL Server or Oracle database, the name of the second pass schema holder is the same as the first pass and should reference a schema holder database that points to the new SecondPass target database. - From
C:/Pro2_SecondPass, open thepredefs.ifile and change the value forSECOND_PASStoYES. - Set the first pass replication thread's disposition to
mark as applied.Note: This preserves the queue records so that the can be replicated on the second pass. As a consequence, you must run manual purges on thereplqueuetable. - From C:/Pro2_SecondPass/bprepl/repl_tmpl, rename the process library
template name in second-pass setup directory.
- For a WAN setup, rename the file
tmpl_replproc_4audit.ptotmpl_asTgtDb.p. - For a LAN setup, rename the file tmpl_replproc_4SECOND_PASS.p to tmpl_replproc.p or current replication template.
- For a WAN setup, rename the file
- Navigate to the Pro2 web interface and select Properties. Edit the
WRI_TRIG_TEMPLATEto reflecttplt_repltrig-raw.pas Value. Click Save. - Navigate back to the Properties tab. Edit the
DEL_TRIG_TEMPLATEto reflecttplt_repltrig-raw.pas the Value. Click Save. - From the \Pro2_secondpass\bprepl\scripts folder, double click the
batchgen_GEN_PROCS.batfile to generate code. - Create and start the second pass replication threads from the
c:\Pro2_SecondPass\bprepl\scriptsfolder.Note: Alternatively, you can create second pass replication threads and control information by loading thereplbasev610-2ndPass.inifile present in the Pro2 folder.
Set up second-pass replication non-audit
To setup second pass replication as non-audit, you follow similar steps as first pass replication. The second pass functions exactly the same as first pass in that when the records on the source database are modified, the changes are replicated to the first pass target, and then replicated to the second pass target. This method of replication always overwrites the existing record instead of creating new records.
batchgen_GEN_PROCS.bat file in Scripts
folder.Additionally, you can reuse the same template from the first pass replication for the
second pass as well for the replication write/delete trigger, and bulk
copy/processor library templates. To bulk load the records to the second pass
target, use the C:\Pro2_secondpass\bprepl\scripts\RunBulkLoader
shortcut.