Trigger Test Sample (SQL-file technology)

This example demonstrates how to create two simple triggers in order to prevent saving wrong values in [_ODD_NUMBERS] table.
All inserted and updated integer values are checked to be odd before the insertion / update.
It is performed in [TR::_ODD_NUMBERS.Insert] and [TR::_ODD_NUMBERS.Update] trigger objects (pieces of T-SQL code).
Source code for the triggers is located in "_ODD_NUMBERS.Insert.sql" and "_ODD_NUMBERS.Update.sql" script files,
in "Triggers" subfolder.

The triggers operate with [_ODD_NUMBERS] table, this name is defined by "set ident_OddNumbersTable=_ODD_NUMBERS" command,
in "@trigger_test.cmd" (SQL-settings in UTF-8).
The table is filled in two steps, which are enfolded in two corresponding transactions.
In the first step only odd numbers are inserted.
In the second step table content is deleted and the table is filled again, but even number is tryed to be inserted,
that is why the second transaction fails.
Only values added at the first table filling step (transaction) remain for permanent storage,
that is displayed as final table content (result-set).

The table is created by translation of "(++) _ODD_NUMBERS.sql" script (it's required for successful sample execution).
Also you have to translate the triggers, two files from "Triggers" subfolder (to protect the table against even numbers).

Main script is in "trigger_test.sql".
Table filling command is "trigger_test.cmd".
The result is normally saved in "trigger_test.txt", or may be seen as translation output in console window etc.

— — —