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.

Pro2 replication triggers are used with the source OpenEdge database. You can use these triggers to:
  • 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 Applied flag 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.

All replication triggers are compression triggers by default.
Note: You cannot use the compression trigger template when Auditing is implemented. You must override the default triggers.

Schema trigger event definitions

Schema triggers are fired when schema-level objects (tables) are modified and when the user log-on or log-off events occur. Some of these triggers are:
  • 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.
To get a trigger definition report from the Procedure Editor (The Procedure Editor is an OpenEdge ABL code editor):
  1. Run Tools > Data Administration.
  2. From the Data Administration window, select Database > Reports > Triggers.

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 1. Progress trigger report
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.

Note that the pathname specified for the Pro2 replication triggers in the schema trigger definition is a relative path starting with 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.

Note:
The types of triggers in Progress are as follows:
  • Primary triggersCREATE, WRITE, and DELETE are primary triggers, and they should not be integrated with Pro2 triggers. They are not affected by Pro2 replication.
  • Replication triggersREPLICATION-DELETE or REPLICATION-WRITE are 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:

  1. Shut down all the database instances and PAS for OpenEdge instance before inserting the replication triggers.
  2. Navigate to the \db folder of Pro2 from the Windows Explorer, for example, C:\Pro2v61\db).
  3. Create a new folder named bprepl in the db folder.
  4. Navigate to the \bprepl folder in the Pro2 folder (C:\Pro2v61\bprepl), and copy the following folders:
    • repl_d
    • repl_w

    These folders contain the replication triggers and are required to process the replication queue records (also known as replq records).

  5. Paste the folders in the \db\bprepl folder of Pro2 (C:\Pro2v61\db\bprepl).
  6. Type prowin -db sports -db repl and press Enter.

    The Procedure Editor window appears.

  7. Open the ReplTrigInsert.p file from C:\Pro2v61\utils in the Procedure Editor window. This inserts replication triggers into the source database.
  8. Enter the name of the source database and close the Procedure Editor .
  9. Restart all the database instances and the PAS for OpenEdge instance.