Book Image

PostgreSQL Server Programming - Second Edition

Book Image

PostgreSQL Server Programming - Second Edition

Overview of this book

Table of Contents (21 chapters)
PostgreSQL Server Programming Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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...