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).
Topics
Initializers
init(trigger:table:when:event:)Create a new trigger creation query.
Instance Properties
bodyOne or more expressions containing procedural SQL statements in the syntax supported by the dialect.columnsA list of zero or more columns to which the trigger is applied, if supported.conditionA predicate determining whether the trigger should execute for a given event, if supported.definerIf 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.eachWhen supported, describes whether the trigger executes on a per-row or per-statement basis.eventThe event the trigger watches for.isConstrainttrueif the new trigger will be a constraint trigger, if supported.nameThe name for the new trigger.orderSpecifies the order of the new trigger with regards to another trigger, in concert withorderTriggerName.orderTriggerNameWhenorderis notnil, specifies the name of the trigger to which the ordering will apply.procedureThe name of a pre-existing stored procedure to invoke as the body of the trigger.referencedTableSpecifies a table referenced by a foreign key constraint for a constraint trigger, if notnil.tableThe table the new trigger is applied to.timingThe deferability status of a constraint trigger with respect to the triggering event, if notnil.whenThe 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
SQLCreateTrigger.EachSpecifierSpecifies whether a trigger executes for each row affected by an event or once for each triggering statement.SQLCreateTrigger.EventSpecifierSpecifies an event which causes a trigger to execute.SQLCreateTrigger.OrderSpecifierSpecifies ordering for a trigger relative to another trigger.SQLCreateTrigger.TimingSpecifierSpecifies the deferability of a contraint trigger vis a vis the associated constraint.SQLCreateTrigger.WhenSpecifierSpecifies how a trigger executes relative to the event that triggers it.
Relationships
Conforms To
SQLExpressionSwift.SendableSwift.SendableMetatype
See Also
Query Expressions
SQLAlterEnumAn expression representing anALTER TYPEquery. Used to add new cases to enumeration types.SQLAlterTableAn expression representing anALTER TABLEquery. Used to modify the structure of existing tables.SQLCreateEnumAn expression representing aCREATE TYPEquery. Used to create enumeration types.SQLCreateIndexAn expression representing aCREATE INDEXquery. Used to add indexes over columns to an existing table.SQLCreateTableAn expression representing aCREATE TABLEquery. Used to create new tables.SQLDeleteAn expression representing aCREATE TRIGGERquery. Used to remove rows from a table.SQLDropEnumAn expression representing aDROP TYPEquery. Used to delete enumeration types.SQLDropIndexAn expression representing aDROP INDEXquery. Used to delete indexes from tables.SQLDropTableAn expression representing aDROP TABLEquery. Used to delete entire tables.SQLDropTriggerAn expression representing aDROP TRIGGERquery. Used to delete triggers.SQLInsertAn expression representing anINSERTquery. Used to add new rows to a table.SQLSelectAn expression representing aSELECTquery. Used to retrieve rows and expression results from a database.SQLUnionAn expression representing two or moreSELECTqueries joined byUNIONclauses. Used to merge the results of multiple queries into a single result set.SQLUpdateAn expression representing anUPDATEquery. Used to modify existing rows in a single table.