The mi_trigger_tabname() function

The mi_trigger_tabname() function returns the triggering table or view name on which the current trigger action statement was started.

Syntax

    mi_string *mi_trigger_tabname(mi_integer flags)
flags
The flags parameter is a combination of any of the following flags:
The following two flags indicate the table information.
MI_TRIGGER_CURRENTTABLE
Return names associated with the current table.
MI_TRIGGER_TOPTABLE
Return names associated with the highest-level table.
The following five flags indicate what information about the table the API returns.
MI_TRIGGER_TABLENAME
Include the table name.
MI_TRIGGER_OWNERNAME
Include the owner name.
MI_TRIGGER_DBASENAME
Include the database name.
MI_TRIGGER_SERVERNAME
Include the server name.
MI_TRIGGER_FULLNAME
Shorthand for all four MI_TRIGGER_*NAME values combined with an OR operation.

If neither MI_TRIGGER_CURRENTTABLE nor MI_TRIGGER_TOPTABLE is defined, you receive the information for the current triggering table. If both are defined, you receive the information for the highest-level table. You can specify any combination of table, owner, database, and server name and the result contains the appropriate punctuation.

Valid in client LIBMI application? Valid in user-defined routine?
No Yes

Usage

The mi_trigger_tabname() function returns the table or view name on which the current trigger action statement was invoked, By using function parameters, you can control the table for which the information is returned and the content of the information returned.

The output value is not safe for embedding into an SQL statement. The components are the names as stored in the system catalog, and may need to be treated specially to be valid in an SQL statement. For example, if the name contains uppercase letters or non-alphanumeric characters (underscore counts as alphanumeric), you would have to have DELIMIDENT set in the environment and you would need to enclose the name in double quotation marks. If the name contains double quotation marks, they would have to be repeated. (Note that the UNIX system call open() provides a precedent for this type of combined flag; the MI_O_RDONLY, MI_ O_WRONLY and MI_O_RDWR flags are mutually exclusive, but one of them can be combined with various other flags such as MI_O_CREAT or MI_O_EXCL.)

In a nested trigger scenario, by default, the current trigger table name is returned. You can get information about the triggering by specifying MI_TOPTABLE. If you specify MI_TOPTABLE in a single-level trigger, you get the current triggering table name.

This function can be called in SPL trigger functions and trigger procedures only within the triggered action list of the FOR EACH ROW clause in trigger definitions.

Return values

database@server:owner.tabname
The full table name (depending on the values in the flags parameter).
database@server:owner.viewname
The full view name (depending on the values in the flags parameter).