Defining Triggers for a Database
A trigger is processing recorded in a database, which automatically triggers on updating a table.
Creating Triggers
Triggers are defined at the level of database tables.

It should be noted that triggers are defined as a function of the target DBMS; this is why it is important to check that the target DBMS is correct before creating triggers.
If the target DBMS is later modified, triggers created for the DBMS are not deleted but deactivated.
To create a trigger:
1. On the desktop, click the navigation menu then Data Architecture > Physical data.
2. In the edit area click Database physical hierarchy.
The list of databases appears in the edit area.
3. Expand the folder of the database then the table concerned.
4. Right-click the Trigger folder and select New > Trigger.
The dialog box for creating a trigger opens.
Trigger triggering
Triggering can occur following one of the three following actions:
• At Creation of a row in the table.
• At Deletion of a row.
• At Modification of the table or of a particular column.
In addition, you can choose to run it Before or After these actions, on the entire table, or on each row concerned.
References
The "Reference of old rows" and "Reference of new rows" fields create in the trigger code references to lines inserted, deleted or updated.
The name indicated in the "Reference of old rows" field corresponds to the line that existed before the update.
The name in the "Reference of new rows" field indicates the line after the update.
In the case of insertion, only the new line is valid.
In the case of deletion, only the old line is valid.
SQL Definition
The SQL Definition option in the properties window of the trigger presents the trigger code.
To access this option you must have "Expert" access to the metamodel.
To display Expert mode:
1. On the HOPEX desktop, click Main Menu > Settings > Options.
2. In the left pane of the window, click the Repository folder.
3. In the right pane of the window, for Repository Access select "Expert" mode.
To display the trigger code:
1. Right-click the trigger and select Properties.
The properties window of the trigger appears.
2. Click the drop-down list then click Texts.
3. Select the SQL Definition tab.
See also: