Use replication triggers
- Last Updated: April 22, 2020
- 4 minute read
Pro2 replication schema triggers are used with the source OpenEdge
Database. A schema trigger is a .p procedure that you add,
through the data dictionary, to the schema of a database. Schema trigger code defined in the
OpenEdge database is executed by database clients.
- Create the replication record based on the database, table, and row ID.
- Record the type of event, (create, write, or delete) that takes place on a record.
- Set the
Appliedflag to false (default). - Define what happens when an event occurs on a record.
When you use an OpenEdge database architecture, the Pro2 replication triggers are executed by the client executable, as opposed to the trigger being executed by the database server executable, as in most other database systems.
The Pro2 trigger procedures are specified by the schema trigger definition. The Pro2 trigger procedures are lightweight and do not alter the your application flow in any way. They are transparent to both the application and the end-users.
In cases where replication triggers already exist in the source database for particular events and tables, the Pro2 replication logic needs to be integrated with or merged into the pre-existing triggers.
Schema trigger event definitions
- CREATE: Creates and enables a database trigger.
- DELETE: Removes a database trigger.
- WRITE: Writes and edits a database trigger.
- RE-DEL (REPLICATION-DELETE): Removes a replication trigger.
- RP-WRI (REPLICATION-WRITE): Creates or updates a replication trigger. The specified procedure is run when this type of event occurs.
- Run .
- From the Data Administration window, select .
The following table is an example of the output from the Progress
trigger report. This example is of a Customer table in the
sports database after Pro2 triggers were inserted:
| Table | Event | CRC | Flags | Procedure |
|---|---|---|---|---|
CUSTOMER
|
CREATE |
No | C:\dlc101c\sports\crcust.p | |
DELETE |
No | C:\dlc101c\sports\delcust.p | ||
RP-DEL |
No | .\bprepl\repl_d\dsports_Customer.t | ||
RP-WRI |
No | .\bprepl\repl_w\wsports_Customer.t | ||
WRITE |
No | C:\dlc101c\sports\wrcust.p |
Alternatively, these triggers can be displayed by the replTrigDisp.p procedure (to display) and the replTrigDisp2.p procedure (to file).
Trigger procedures
The Pro2 trigger procedures are found by the client executable in a
location specified in the PROPATH. The replication
trigger location can be in the same directory as the other triggers (if there are
other triggers defined for the database). However, these triggers must be already
included in the PROPATH. You must place the
trigger procedures on the database server and on any application servers that end
users run your application.
bprepl. Typically, a bprepl directory is
created with the following sub-directories in a location already in the PROPATH:repl_d(delete triggers)repl_w(write triggers)
PROPATH can be modified to include the location of
the bprepl directory.When a replication trigger is defined for a table schema, the client attempts to run the specified trigger procedure. This happens when a client executable attempts to update a record in the source database.
The trigger procedures should be located on the database server if the user is connected as a local direct connect client (whether an end user or by PAS for OpenEdge servicing a remote client). Whereas, the trigger procedures should be on the client system if they are remote and are connected to the database via client/server.
For optimal performance, the replication triggers should be compiled
with.r code. To compile the triggers, the
standard OpenEdge application compiler is used in a Procedure Editor session
connected to both the source database and the repl database.
Merged triggers
The Pro2 replication triggers must be merged with the original
triggers if the pre-existing replication triggers
(REPLICATION-DELETE or REPLICATION-WRITE)
exist in the source database. You can merge the triggers by adding a RUN statement
in the original replication trigger procedure that calls the Pro2 trigger or by
adding the Pro2 replication trigger logic to the original trigger.
- Primary
triggers—
CREATE,WRITE, andDELETEare primary triggers, and they should not be integrated with Pro2 triggers. They are not affected by Pro2 replication. - Replication triggers—
REPLICATION-DELETEorREPLICATION-WRITEare executed after the primary triggers and must be merged with the Pro2 triggers.
Insert replication triggers
The replTrigInsert.p procedure is
used to insert the triggers. This procedure is run from the OpenEdge procedure
editor connected to both the source database and the repl database (or to the source
database with the embedded repl tables).
To insert replication triggers:
- Shut down all the database instances and PAS for OpenEdge instance before inserting the replication triggers.
- Navigate to the \db folder of Pro2 from the Windows Explorer, for example, C:\Pro2v61\db).
- Create a new folder named bprepl in the
dbfolder. - Navigate to the
\bpreplfolder in the Pro2 folder (C:\Pro2v61\bprepl), and copy the following folders:repl_drepl_w
These folders contain the replication triggers and are required to process the replication queue records (also known as replq records).
- Paste the folders in the \db\bprepl folder of Pro2 (C:\Pro2v61\db\bprepl).
- Type prowin -db sports -db
repl and click Enter.
The Procedure Editor window appears. This will insert replication triggers in the source database (
sports). - Open the
ReplTrigInsert.pfile from C:\Pro2v61\utils in the Procedure Editor window. - Enter the name of the source database (
sports). Close the Procedure Editor . - Restart all the database instances and the PAS for OpenEdge instance.