Trigger information
You can create user-defined routines that are invoked in trigger action statements to obtain information about the triggers, triggering tables, views, statements, and the values of rows involved in the trigger actions.
To create such a reporting routine, use the DataBlade® API functions in the following table. Using these DataBlade® API functions, you can write a general purpose user-defined routine that you can use to audit any table and any trigger event. You can use mi_trigger functions in the triggered action list of the FOR EACH ROW clause.
DataBlade® API function | Purpose |
---|---|
mi_trigger_event() | Returns the value derived from an OR operation
from the following events. These values are defined in the milib.h file.
Each bit set in the returned value indicates the type of trigger currently executing. These definitions are in the public header file. The returned value is combined with these values to determine the current event. If the UDR is not currently executing, it returns MI_TRIGGER_NOT_IN_EVENT. |
mi_trigger_get_new_row() | Returns the new row being inserted or the updated value of the row. It returns NULL when called in other trigger action statements. |
mi_trigger_get_old_row() | Returns the row that was deleted or the value of the row before it was updated. It returns all the columns in the requested row, not just those columns into which data was explicitly inserted. Columns with default data are also returned. It returns NULL when called in other trigger action statements. |
mi_trigger_level() | Returns the nesting level of the current trigger. The values returned begin at 1 and increment by 1 for each nesting level, with a maximum of 61 levels. |
mi_trigger_name() | Returns the name of the currently executing trigger
in the format ownername.triggername . |
mi_trigger_tabname() | Returns the triggering table or view name. |
For the syntax of these functions and for more information about their purposes, see the Informix® DataBlade® API Function Reference.