0% found this document useful (0 votes)
10 views2 pages

ASSIGNMENT

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

ASSIGNMENT

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

HU22CSEN0100515

D.CHANDAN

Assignment 9 : Assignment-10

Consider the customer table as (cid number, name string, address string, salary
number).
1.Create an update trigger that displays salary changes for every salary updation in customer
table
CREATE OR REPLACE TRIGGER salary_update_notification
AFTER UPDATE OF salary ON customer
FOR EACH ROW
BEGIN
DBMS_OUTPUT.PUT_LINE('Customer ID: ' || :OLD.cid || ' - Salary changed from '
|| :OLD.salary || ' to ' || :NEW.salary);
END salary_update_notification;
/
HU22CSEN0100515
D.CHANDAN

2.Create a trigger that displays message if the employee table is accessed beyond office hours
(before 10am and after 5pm).
CREATE OR REPLACE TRIGGER employee_access_off_hours
BEFORE INSERT OR UPDATE OR DELETE OR SELECT ON employee
DECLARE
current_hour NUMBER;
BEGIN
current_hour := TO_NUMBER(TO_CHAR(SYSDATE, 'HH24'));

IF current_hour < 10 OR current_hour > 17 THEN


DBMS_OUTPUT.PUT_LINE('Warning: Accessing employee table outside office
hours.');
END IF;
END employee_access_off_hours;
/

3.Create a statement level trigger and row level trigger for employee data insertion operation
CREATE OR REPLACE TRIGGER employee_insert_statement
AFTER INSERT ON employee
BEGIN
DBMS_OUTPUT.PUT_LINE('Employee data insert operation executed at the statement
level.');
END employee_insert_statement;
/

You might also like