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
var body: [any SQLExpression]?One or more expressions containing procedural SQL statements in the syntax supported by the dialect.var columns: [any SQLExpression]?A list of zero or more columns to which the trigger is applied, if supported.var condition: (any SQLExpression)?A predicate determining whether the trigger should execute for a given event, if supported.var definer: (any SQLExpression)?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.var each: (any SQLExpression)?When supported, describes whether the trigger executes on a per-row or per-statement basis.var event: any SQLExpressionThe event the trigger watches for.var isConstraint: Booltrueif the new trigger will be a constraint trigger, if supported.var name: any SQLExpressionThe name for the new trigger.var order: (any SQLExpression)?Specifies the order of the new trigger with regards to another trigger, in concert withorderTriggerName.var orderTriggerName: (any SQLExpression)?Whenorderis notnil, specifies the name of the trigger to which the ordering will apply.var procedure: (any SQLExpression)?The name of a pre-existing stored procedure to invoke as the body of the trigger.var referencedTable: (any SQLExpression)?Specifies a table referenced by a foreign key constraint for a constraint trigger, if notnil.var table: any SQLExpressionThe table the new trigger is applied to.var timing: (any SQLExpression)?The deferability status of a constraint trigger with respect to the triggering event, if notnil.var when: any SQLExpressionThe ordering of the trigger’s execution relative to the triggering event.
Instance Methods
func serialize(to: inout SQLSerializer)Invoked when a request is made to serialize the expression to raw SQL.
Enumerations
enum EachSpecifierSpecifies whether a trigger executes for each row affected by an event or once for each triggering statement.enum EventSpecifierSpecifies an event which causes a trigger to execute.enum OrderSpecifierSpecifies ordering for a trigger relative to another trigger.enum TimingSpecifierSpecifies the deferability of a contraint trigger vis a vis the associated constraint.enum WhenSpecifierSpecifies how a trigger executes relative to the event that triggers it.
Relationships
Conforms To
SQLExpressionSwift.SendableSwift.SendableMetatype
See Also
Query Expressions
struct SQLAlterEnumAn expression representing anALTER TYPEquery. Used to add new cases to enumeration types.struct SQLAlterTableAn expression representing anALTER TABLEquery. Used to modify the structure of existing tables.struct SQLCreateEnumAn expression representing aCREATE TYPEquery. Used to create enumeration types.struct SQLCreateIndexAn expression representing aCREATE INDEXquery. Used to add indexes over columns to an existing table.struct SQLCreateTableAn expression representing aCREATE TABLEquery. Used to create new tables.struct SQLDeleteAn expression representing aCREATE TRIGGERquery. Used to remove rows from a table.struct SQLDropEnumAn expression representing aDROP TYPEquery. Used to delete enumeration types.struct SQLDropIndexAn expression representing aDROP INDEXquery. Used to delete indexes from tables.struct SQLDropTableAn expression representing aDROP TABLEquery. Used to delete entire tables.struct SQLDropTriggerAn expression representing aDROP TRIGGERquery. Used to delete triggers.struct SQLInsertAn expression representing anINSERTquery. Used to add new rows to a table.struct SQLSelectAn expression representing aSELECTquery. Used to retrieve rows and expression results from a database.struct SQLUnionAn expression representing two or moreSELECTqueries joined byUNIONclauses. Used to merge the results of multiple queries into a single result set.struct SQLUpdateAn expression representing anUPDATEquery. Used to modify existing rows in a single table.