What are triggers, and when would you use them?

Answer Posted / glibwaresoftsolutions

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

Is primary key clustered index?

690


Which is better varchar or nvarchar?

738


How many row comparison operators are used while working with a subquery?

756


What is sqlerrm?

713


Is sql better than access?

716






What is trigger types of trigger?

722


why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba

792


How does one use sql*loader to load images, sound clips and documents? : aql loader

886


What is the size of partition table?

742


Does truncate release storage space?

769


What is a sql select statement?

767


Why are sql stored procedures used?

800


table structure: ---------------- col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10 01-mar-2012 11:12:46 01-mar-2012 11:11:23 Write a query to display the result as shown below: col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10

3719


Why we use stored procedure instead of query?

710


How to read/write files from pl/sql?

774