What is a Trigger?

Advantage Concepts

A trigger is a piece of code (similar to a stored procedure) that is executed on the server. Triggers differ from stored procedures because triggers are not called by the client, but instead are executed automatically in response to an insert, update, or delete operation.

Triggers are supported for both SQL and navigational update operations. Throughout this documentation the update operations will be specified using uppercase notation (for example, INSERT), but this does not imply an SQL-only limitation.

When a trigger is "fired" it contains some state information, which can be used inside the body of the trigger. Two in-memory tables are available inside a trigger; a __new table and an __old table. The __new table contains new field values that were, or are about to be, inserted into the table. The __old table contains old field values for the record in question.

Triggers can provide a very powerful means to maintain business rules inside of a database.

Triggers can be defined for any supported table type, and are not limited to the proprietary ADT format.

Both the Advantage Database Server and the Advantage Local Server support triggers. Implicit Transactions are the only trigger functionality that differ depending on server type.

Trigger support is a server-side feature. Any Advantage client version 6.0 or greater capable of opening a dictionary-bound table can utilize triggers. This can be beneficial if you want to add trigger support to your application, but donít want to upgrade your client applications. Only the database server needs to be upgraded (to Advantage version 7.0 or greater) in order to start using triggers.