filmov
tv
PL SQL Triggers || Triggers in PL/SQL || PL/SQL Tutorial for Beginners in Hindi

Показать описание
A trigger is a named PL/SQL block stored in the Oracle Database and executed automatically when a triggering event takes place.
What is PL SQL Trigger: 00:00:02
Syntax of Triggers: 00:01:53
Detailed Example: 00:03:06
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Create Audit Table where we will be logging the transaction details:
create table audits
(auditid number generated by default as identity primary key,
tableName varchar2(200),
transactionName varchar2(10),
userName varchar2(30),
transactionDate Date);
Use any table created by you in place of Customers in the below trigger.
CREATE OR REPLACE TRIGGER customersAuditTRG
AFTER
UPDATE OR DELETE
ON customers
FOR EACH ROW
DECLARE
transaction VARCHAR2(10);
BEGIN
-- determine the transaction type
transaction := CASE
WHEN UPDATING THEN 'UPDATE'
WHEN DELETING THEN 'DELETE'
END;
-- insert a row into the audit table
INSERT INTO audits (tableName, transactionName, userName, transactionDate)
VALUES('CUSTOMERS', transaction, USER, SYSDATE);
END;
/
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Please like & share the video.
Subscribe the Channel to keep watching interesting videos helpful for your career growth:
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Checkout different playlists:
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Checkout Important videos :
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
What is PL SQL Trigger: 00:00:02
Syntax of Triggers: 00:01:53
Detailed Example: 00:03:06
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Create Audit Table where we will be logging the transaction details:
create table audits
(auditid number generated by default as identity primary key,
tableName varchar2(200),
transactionName varchar2(10),
userName varchar2(30),
transactionDate Date);
Use any table created by you in place of Customers in the below trigger.
CREATE OR REPLACE TRIGGER customersAuditTRG
AFTER
UPDATE OR DELETE
ON customers
FOR EACH ROW
DECLARE
transaction VARCHAR2(10);
BEGIN
-- determine the transaction type
transaction := CASE
WHEN UPDATING THEN 'UPDATE'
WHEN DELETING THEN 'DELETE'
END;
-- insert a row into the audit table
INSERT INTO audits (tableName, transactionName, userName, transactionDate)
VALUES('CUSTOMERS', transaction, USER, SYSDATE);
END;
/
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Please like & share the video.
Subscribe the Channel to keep watching interesting videos helpful for your career growth:
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Checkout different playlists:
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Checkout Important videos :
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Комментарии