Struct CreateTrigger
pub struct CreateTrigger {Show 17 fields
pub or_alter: bool,
pub or_replace: bool,
pub is_constraint: bool,
pub name: ObjectName,
pub period: TriggerPeriod,
pub period_before_table: bool,
pub events: Vec<TriggerEvent>,
pub table_name: ObjectName,
pub referenced_table_name: Option<ObjectName>,
pub referencing: Vec<TriggerReferencing>,
pub trigger_object: TriggerObject,
pub include_each: bool,
pub condition: Option<Expr>,
pub exec_body: Option<TriggerExecBody>,
pub statements_as: bool,
pub statements: Option<ConditionalStatements>,
pub characteristics: Option<ConstraintCharacteristics>,
}Expand description
CREATE TRIGGER
Examples:
CREATE TRIGGER trigger_name
BEFORE INSERT ON table_name
FOR EACH ROW
EXECUTE FUNCTION trigger_function();Postgres: https://www.postgresql.org/docs/current/sql-createtrigger.html SQL Server: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql
Fields§
§or_alter: boolTrue if this is a CREATE OR ALTER TRIGGER statement
or_replace: boolThe OR REPLACE clause is used to re-create the trigger if it already exists.
Example:
CREATE OR REPLACE TRIGGER trigger_name
AFTER INSERT ON table_name
FOR EACH ROW
EXECUTE FUNCTION trigger_function();is_constraint: boolThe CONSTRAINT keyword is used to create a trigger as a constraint.
name: ObjectNameThe name of the trigger to be created.
period: TriggerPeriodDetermines whether the function is called before, after, or instead of the event.
Example of BEFORE:
CREATE TRIGGER trigger_name
BEFORE INSERT ON table_name
FOR EACH ROW
EXECUTE FUNCTION trigger_function();Example of AFTER:
CREATE TRIGGER trigger_name
AFTER INSERT ON table_name
FOR EACH ROW
EXECUTE FUNCTION trigger_function();Example of INSTEAD OF:
CREATE TRIGGER trigger_name
INSTEAD OF INSERT ON table_name
FOR EACH ROW
EXECUTE FUNCTION trigger_function();period_before_table: boolWhether the trigger period was specified before the target table name.
-- period_before_table == true: Postgres, MySQL, and standard SQL
CREATE TRIGGER t BEFORE INSERT ON table_name ...;
-- period_before_table == false: MSSQL
CREATE TRIGGER t ON table_name BEFORE INSERT ...;events: Vec<TriggerEvent>Multiple events can be specified using OR, such as INSERT, UPDATE, DELETE, or TRUNCATE.
table_name: ObjectNameThe table on which the trigger is to be created.
referenced_table_name: Option<ObjectName>The optional referenced table name that can be referenced via
the FROM keyword.
referencing: Vec<TriggerReferencing>This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement.
trigger_object: TriggerObjectThis specifies whether the trigger function should be fired once for every row affected by the trigger event, or just once per SQL statement.
include_each: boolWhether to include the EACH term of the FOR EACH, as it is optional syntax.
condition: Option<Expr>Triggering conditions
exec_body: Option<TriggerExecBody>Execute logic block
statements_as: boolFor MSSQL and dialects where statements are preceded by AS
statements: Option<ConditionalStatements>For SQL dialects with statement(s) for a body
characteristics: Option<ConstraintCharacteristics>The characteristic of the trigger, which include whether the trigger is DEFERRABLE, INITIALLY DEFERRED, or INITIALLY IMMEDIATE,
Trait Implementations§
§impl Clone for CreateTrigger
impl Clone for CreateTrigger
§fn clone(&self) -> CreateTrigger
fn clone(&self) -> CreateTrigger
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for CreateTrigger
impl Debug for CreateTrigger
§impl Display for CreateTrigger
impl Display for CreateTrigger
§impl From<CreateTrigger> for Statement
impl From<CreateTrigger> for Statement
§fn from(c: CreateTrigger) -> Statement
fn from(c: CreateTrigger) -> Statement
§impl Hash for CreateTrigger
impl Hash for CreateTrigger
§impl Ord for CreateTrigger
impl Ord for CreateTrigger
§impl PartialEq for CreateTrigger
impl PartialEq for CreateTrigger
§impl PartialOrd for CreateTrigger
impl PartialOrd for CreateTrigger
§impl Visit for CreateTrigger
impl Visit for CreateTrigger
§impl VisitMut for CreateTrigger
impl VisitMut for CreateTrigger
fn visit<V>(&mut self, visitor: &mut V) -> ControlFlow<<V as VisitorMut>::Break>where
V: VisitorMut,
impl Eq for CreateTrigger
impl StructuralPartialEq for CreateTrigger
Auto Trait Implementations§
impl Freeze for CreateTrigger
impl RefUnwindSafe for CreateTrigger
impl Send for CreateTrigger
impl Sync for CreateTrigger
impl Unpin for CreateTrigger
impl UnwindSafe for CreateTrigger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.