Tech Tip: Enabling and disabling triggers of a table at runtime
PRODUCT: 4D | VERSION: 15 | PLATFORM: Mac & Win
Published On: July 23, 2015
A database may have issues in trying to save or delete records of a particular table. One way to debug the issue would be to turn off the triggers of a table to rule out if it relates to the trigger event. Here is a utlity method ENABLE_DISABLE_TABLE_TRIGGERS:
// ------------------------------------------------------------------------ // Name: ENABLE_DISABLE_TABLE_TRIGGERS // Description: Method will enable or disable triggers of a specified table // // Parameters: // $1 (Pointer) - Table specified. // $2 (Boolean) - True - Enable Triggers, False - Disable Triggers // ------------------------------------------------------------------------ C_POINTER($1;$table) C_BOOLEAN($2;$choice) C_TEXT($textQuery) If (Count parameters=2) $table:=$1 $choice:=$2 If ($choice=true) $textQuery:="ALTER TABLE "+table name($table)+" enable Triggers" Else $textQuery:="ALTER TABLE "+table name($table)+" disable Triggers" End if Begin SQL EXECUTE IMMEDIATE: $textQuery; End SQL End if |
Here is a example of disabling the triggers of a table:
ENABLE_DISABLE_TABLE_TRIGGERS(->[Table];false) |
Here is a example of enabling the triggers of a table:
ENABLE_DISABLE_TABLE_TRIGGERS(->[Table];true) |
Running these examples and then modifying the record of that table would be a quick test to see if the issue as at the trigger level.