Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


SQL Triggers concept in IBM i DB2

SQL Triggers concept in IBM i DB2
SQL Triggers concept in IBM i DB2, introduction, create, about, what, what is, sql trigger, trigger, as400, ibmi, iseries, db2, sql, db2 for i sql
SQL Triggers concept in IBM i DB2

Introduction

Triggers provide the way to monitor, alter, and manage the tables when any insert, delete or add operation occurs on the table.

It is very helpful when there is huge dependency present between the tables or if any specific action has to be performed when there is any change happening in the table.

Below are some points to understand the trigger better:

Tracks Database Activity

The trigger gets active only in the case when there is any change happening on the trigger associated table like add, delete and insert.

Enforce Bussiness Rules / Ensure data consistency in the database

In case, when there are multiple tables that are co-related to each other then all the related tables will get in synch with each other when any changes are applied on the trigger associated table and further the action performed by the trigger alters the related table to bring them in synch. 

Trigger Concept 

When the trigger is executed a certain set of actions are performed.

Insert,Delete,Update on Table/View

A trigger can be added on insert, delete, the addition of the record in the table or in the View.

Called By Database

When certain actions are performed by the trigger then the actions are called by the database (database management system) itself.

Perform non-database operations

The trigger can also be used by sending messages, email, or other non-database-related operations. 

Trigger Cascading

There's also a concept of cascading trigger which will execute the chain of triggers performing multiple sets of action across the application.

Support column-level granularity

A trigger can be added to a specific column of the table rather than the table itself.

Stored procedure/ UDF

SQL triggers are invoked through the database management system on the execution of the triggering operation and it can call SQL stored procedure or UDF.

Related Post

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain