Variables passed to the PL/pgSQL TRIGGER function

The following is a complete list of the variables available to a trigger function written in PL/pgSQL:

OLD, NEW

RECORD

This records the before and after images of the row on which the trigger is called. OLD is unassigned for INSERT and NEW is unassigned for DELETE.

Both are UNASSIGNED in statement-level triggers.

TG_NAME

name

This denotes the name of the trigger (this and following from the trigger definition).

TG_WHEN

text

BEFORE, AFTER, or INSTEAD OF are the possible values of the variable.

TG_LEVEL

text

ROW or STATEMENT are the possible values of the variable.

TG_OP

text

INSERT, UPDATE, DELETE, or TRUNCATE are the possible values of the variable..

TG_RELID

oid

This denotes the OID of the table on which the trigger is created.

TG_TABLE_NAME

name

This denotes the name of the table (the old spelling TG_RELNAME is deprecated but still available).

TG_TABLE_SCHEMA

name

This denotes the schema name of the table.

TG_NARGS, TG_ARGV[]

Int, text[]

This denotes the number of arguments and the array of the arguments from the trigger definition.

TG_TAG

text

This is used in DDL or event triggers. This variable contains the name of the command that resulted in the trigger invocation. More information on this in the next chapter.

You can read more about the variables at http://www.postgresql.org/docs/current/static/plpgsql-trigger.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.66.67