What are triggers, and when would you use them?

Answer Posted / hr@tgksolutions.com

A trigger is a block of PL/SQL code automatically executed in response to certain events (e.g., INSERT, UPDATE, DELETE) on a table.
Example Trigger:
CREATE OR REPLACE TRIGGER EmployeeAudit
AFTER INSERT ON employees
FOR EACH ROW
BEGIN
INSERT INTO audit_log(employee_id, action, action_date)
VALUES (:NEW.id, 'INSERT', SYSDATE);
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is embedded sql what are its advantages?

692


what are integrity rules?

754


What is the command used to fetch the first 5 characters of a string?

931


what are the advantages of using stored procedures? : Sql dba

824


How to use distinct and count in sql query? Explain

769






Which sql statement is used to return only different values?

716


Can we use pl sql in sql server?

739


What is basic structure of pl sql?

688


How many types of functions are there in sql?

666


What is sql partition function?

804


describe mysql connection using mysql binary. : Sql dba

754


How do you declare a user-defined exception?

722


What do you know by pl/sql cursors?

759


How can I get the number of records affected by a stored procedure?

767


Is there any restriction on the use of union in embedded sql?

883