Audit updates with old and new values
SQL
Medium
0 views
Problem Description
On Employees salary update, insert into SalaryAudit(emp_id, old_salary, new_salary, changed_at).
Output Format
Trigger created
Sample Test Case
Input:
Employees, SalaryAudit
Constraints
SalaryAudit exists
Official Solution
CREATE TRIGGER trg_salary_audit AFTER UPDATE ON Employees FOR EACH ROW INSERT INTO SalaryAudit(emp_id, old_salary, new_salary, changed_at) VALUES (OLD.emp_id, OLD.salary, NEW.salary, CURRENT_TIMESTAMP);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!