TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramith Serasingha
NA
3
620
database triggers
Mar 9 2021 4:11 PM
CREATE
OR
REPLACE
TRIGGER
audit-
table
-DEPT
AFTER
INSERT
OR
UPDATE
OR
DELETE
ON
DEPT
FOR
EACH ROW
declare
audit_data DEPT$audit%ROWTYPE;
begin
if inserting
then
audit_data.change_type :=
'I'
;
elsif updating
then
audit_data.change_type :=
'U'
;
else
audit_data.change_type :=
'D'
;
end
if;
audit_data.changed_by :=
user
;
audit_data.changed_time := sysdate;
case
audit_data.change_type
when
'I'
then
audit_data.DEPTNO := :new.DEPTNO;
audit_data.DNAME := :new.DNAME;
audit_data.LOC := :new.LOC;
else
audit_data.DEPTNO := :old.DEPTNO;
audit_data.DNAME := :old.DNAME;
audit_data.LOC := :old.LOC;
end
case
;
insert
into
DEPT$audit
values
audit_data;
end
;
Trigger created.
(i) What would happen when the trigger is fired?
(ii) Discuss how this can affect normal database operations.
Reply
Answers (
1
)
A commit after a truncate table
List all schema´s object