I want to create a trigger that updates a particular attribute for all the tuples of a table, before a new tuple is inserted.
So whenever I run INSERT INTO Employee VALUES (...);
I want the salary of all previously stored employees to be decreased by 300, that is, UPDATE Employee SET Salary = Salary - 300;
I'm really new to SQL so I naively tried the following:
CREATE TRIGGER reducesalary BEFORE INSERT ON Employee
FOR EACH ROW
UPDATE Employee SET Salary = Salary - 300;
Of course, I then found out this is incorrect since triggers cannot work on the same table that calls them. How do I go about doing this?