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

preview_player
Показать описание
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 :

--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Whatever you explain are very helpful in our live projects, previously I was not able to do much in plsql, but only because of your videos I am creating the same ....thank you so much for these informative videos
Here one request, please upload more videos regarding live example of procedure, function triggers....which going to be very helpful for us....
Again keep going 😊

prashantp
Автор

The way you are explaining is amazing 😍🤩🎉, watch once remember lifetime 😂(WORL like WORA)

narendramore
Автор

Please upload some more live example....these are really helpful

prashantp
Автор

Really helpful videos of Psql and glad that I got to know about the channel. Sir can you please help in data analytics is they use Psql

AkashGupta-cikg
Автор

I'm trying the same code in toad but in the v_transaction name it doesn't pick the update or delete, but insert the name of variable itself

TAGamerz
Автор

Mai trigger create karraha hun toh cannot create trigger on sys jaisa kuch aaraha h please help kijiye 🙏🙏🙏

randomfun
Автор

hii biplab sir when i am createing audit table by your mentioned commands in sql developer it is giving this error-

Error starting at line : 1 in command -
create table audits
(auditid number generated by default as identity primary key,
tableName varchar2(200),
transactionName varchar2(10),
userName varchar2(30),
transactionDate Date)
Error report -
ORA-02000: missing ALWAYS keyword
02000. - "missing %s keyword"


please give a solution.🙏

ShubhamShukla-jl
Автор

hii biplab sir i am creating audit table in sql developer but it is giving this error--

Error starting at line : 1 in command -
create table audits
(auditid number generated by default as identity primary key,
tableName varchar2(200),
transactionName varchar2(10),
userName varchar2(30),
transactionDate Date)
Error report -
ORA-02000: missing ALWAYS keyword
02000. - "missing %s keyword"


please give a solution sir

ShubhamShukla-jl
Автор

hii biplab sir when i am createing audit table by your mentioned commands in sql developer it is giving this error-

Error starting at line : 1 in command -
create table audits
(auditid number generated by default as identity primary key,
tableName varchar2(200),
transactionName varchar2(10),
userName varchar2(30),
transactionDate Date)
Error report -
ORA-02000: missing ALWAYS keyword
02000. - "missing %s keyword"


please give a solution.🙏

ShubhamShukla-jl