O'Reilly logo

PostgreSQL Server Programming by Jim Mlodgenski, Kirk Roybal, Hannu Krosing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variables passed to the PL/pgSQL TRIGGER function

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

OLD, NEW

RECORD

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

Both are UNASSIGNED in statement-level triggers.

TG_NAME

name

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

TG_WHEN

text

One of BEFORE, AFTER, or INSTEAD OF.

TG_LEVEL

text

ROW or STATEMENT.

TG_OP

text

One of INSERT, UPDATE, DELETE, or TRUNCATE.

TG_RELID

oid

OID of the table the trigger is created on.

TG_TABLE_NAME

name

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

TG_TABLE_SCHEMA ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required