Skip to content

Structure

SQLCreateTrigger

An expression representing a CREATE TRIGGER query. Used to create new triggers for actions on a table.
struct SQLCreateTrigger

Overview

CREATE CONSTRAINT TRIGGER "trigger"
    DEFINER=foo
    AFTER UPDATE OF "column1", "column2" ON "table"
    FROM "other_table" NOT DEFERRABLE
    FOR EACH ROW
    WHEN ("column3"="four")
    FOLLOWS "other_trigger"
BEGIN
    ...
END;

When used with the PostgreSQL driver, SQLCreateTrigger performs strong validation of its properties with respect to PostgreSQL’s syntax restrictions. In general, the dialect specifies in granular detail exactly which features it supports; properties specifying features not supported by the dialect are generally ignored, except with respect to the trigger body/procedure and the definer (if specified), which are validated by assertion (a runtime error results from invalid use in debug builds, whereas invalid syntax is silently emitted in release builds so that the database will report the issue).

See SQLCreateTriggerBuilder.

Topics

Initializers

Instance Properties

  • body
    One or more expressions containing procedural SQL statements in the syntax supported by the dialect.
  • columns
    A list of zero or more columns to which the trigger is applied, if supported.
  • condition
    A predicate determining whether the trigger should execute for a given event, if supported.
  • definer
    If supported by dialect, a user or role to be treated as the trigger’s owner for purposes of determining the privileges available to the trigger’s body.
  • each
    When supported, describes whether the trigger executes on a per-row or per-statement basis.
  • event
    The event the trigger watches for.
  • isConstraint
    true if the new trigger will be a constraint trigger, if supported.
  • name
    The name for the new trigger.
  • order
    Specifies the order of the new trigger with regards to another trigger, in concert with orderTriggerName.
  • orderTriggerName
    When order is not nil, specifies the name of the trigger to which the ordering will apply.
  • procedure
    The name of a pre-existing stored procedure to invoke as the body of the trigger.
  • referencedTable
    Specifies a table referenced by a foreign key constraint for a constraint trigger, if not nil.
  • table
    The table the new trigger is applied to.
  • timing
    The deferability status of a constraint trigger with respect to the triggering event, if not nil.
  • when
    The ordering of the trigger’s execution relative to the triggering event.

Instance Methods

  • serialize(to:)
    Invoked when a request is made to serialize the expression to raw SQL.

Enumerations

Relationships

Conforms To

See Also

Query Expressions

  • SQLAlterEnum
    An expression representing an ALTER TYPE query. Used to add new cases to enumeration types.
  • SQLAlterTable
    An expression representing an ALTER TABLE query. Used to modify the structure of existing tables.
  • SQLCreateEnum
    An expression representing a CREATE TYPE query. Used to create enumeration types.
  • SQLCreateIndex
    An expression representing a CREATE INDEX query. Used to add indexes over columns to an existing table.
  • SQLCreateTable
    An expression representing a CREATE TABLE query. Used to create new tables.
  • SQLDelete
    An expression representing a CREATE TRIGGER query. Used to remove rows from a table.
  • SQLDropEnum
    An expression representing a DROP TYPE query. Used to delete enumeration types.
  • SQLDropIndex
    An expression representing a DROP INDEX query. Used to delete indexes from tables.
  • SQLDropTable
    An expression representing a DROP TABLE query. Used to delete entire tables.
  • SQLDropTrigger
    An expression representing a DROP TRIGGER query. Used to delete triggers.
  • SQLInsert
    An expression representing an INSERT query. Used to add new rows to a table.
  • SQLSelect
    An expression representing a SELECT query. Used to retrieve rows and expression results from a database.
  • SQLUnion
    An expression representing two or more SELECT queries joined by UNION clauses. Used to merge the results of multiple queries into a single result set.
  • SQLUpdate
    An expression representing an UPDATE query. Used to modify existing rows in a single table.