Online Documentation for SQL Manager for InterBase/Firebird
Creating/editing trigger
Use the Trigger tab of Trigger Editor to view and edit the trigger definition.
Trigger Editor provides two modes: Text editor and Visual editor. To switch between these editor modes, use the corresponding items available in the General group of the Navigation bar and toolbar.
When in the Text editor mode, you can use the editor area to specify the trigger definition as SQL statement using a template, hence it is enough to simply edit the template using the editor area to make appropriate changes, and compile the trigger.
For your convenience the syntax highlight, code completion and a number of other features for efficient SQL editing are implemented. For details see Working with query and Using the context menu.
When in the Visual editor mode, you are provided with a set of widgets allowing you to benefit from graphical user interface while editing the object properties.
Name
Enter a name for the new trigger, or modify the name of the trigger being edited. Note that trigger name must be unique in the database.
For table
The drop-down list of tables and views allows you to select the table or view on which the trigger is executed.
Type
Select the trigger behavior type:
Before
This selection specifies that the trigger is fired before the triggering SQL statement.
After
This selection specifies that the trigger is fired only when all operations specified in the triggering SQL statement have executed successfully.
On event
Specify the data modification statement(s) that activate the trigger when it is tried against this table or view:
Insert
Update
Delete
Position
Defines the order of firing triggers on the same event. Lower-number triggers fire first, thus trigger with the default position (0) will be the first trigger to fire.
Is active
Activates/deactivates the trigger immediately after it is created. A disabled (inactive) trigger still exists as an object in the database, but does not fire.
Variables
This group is provided for managing the list of local variables declared and used only in the trigger.
The Variables list provides the following attributes of each variable used in the trigger:
Name (name of the variable, unique for variables within the trigger)
Default Value (a default value for the variable)
Variable Type (the data type of the variable, click the arrow-down button to call Data Type Editor for setting properties of the variable data type)
Description (description of the variable)
Right-click the area to display the context menu allowing you to append, insert, delete the selected variable, or move it up/down.
Variables management tools are also available through the Navigation bar and toolbar of Trigger Editor.
The Data Type Editor popup window allows you to define variable data type properties.
Parameter based on
This group allows you to select the source type for the variable being created/edited. It can be one of existing domains, a standard InterBase/Firebird data type or a column.
Data type
Specifies that the parameter is based on a standard data type.
Domain
Specifies that the parameter is based on a domain previously created in the database. Note that creating parameters based on a domain is only available for Firebird 2.1 and later.
Column
Specifies that the parameter is based on a field.
Variable
This group allows you to select the data type / domain / column and set properties specific for this data type / domain / column. For details see Domain options, Options for standard data type.
Cursors
This group is provided for managing the list of cursors declared to define sets of rows that can be retrieved using the cursor.
The Cursors list provides the following attributes of each cursor used in the trigger:
Name (cursor name)
Query (the SELECT query that determines which rows to retrieve, click the arrow-down button to call Query Data editor for editing the query text)
Description (description of the cursor)
The Query Data popup window allows you to specify the SELECT query.
For your convenience the syntax highlight, code completion and a number of other features for efficient SQL editing are implemented. For details see Working with query and Using the context menu.
If more convenient, you can click the button to call Query Designer for building the query visually.
The lower area allows you to specify the trigger body, i.e. an optional list of local variables and their data types and a block of statements in InterBase procedure and trigger language, bracketed by BEGIN and END. These statements are performed when the trigger fires. When editing the trigger, you can edit its body using the editor area to make appropriate changes, and recompile the trigger.
To compile a trigger, you can use the Compile item available within the Navigation bar or toolbar.