CREATE OR REPLACE TRIGGER stock_update
ON Stock
FOR UPDATE
AS
BEGIN
INSERT INTO stock_log
(stkcode, old_stkprice, new_stkprice, old_stkqty, new_stkqty, update_stktime)
SELECT d.stkcode, d.stkprice, i.stkprice, d.stkqty, i.stkqty, CURRENT_TIMESTAMP
FROM deleted d, inserted i
where d.stkcode = i.stkcode
END
GO
In this trigger we are inserting values to stock_log table by fetching values from deleted and inserted stock table using
SELECT d.stkcode, d.stkprice, i.stkprice, d.stkqty, i.stkqty, CURRENT_TIMESTAMP
FROM deleted d, inserted i
where d.stkcode = i.stkcode
(during update there will be two table maintained by the DMBS
1. is old or deleted
2. is new or updated or inserted )
Please help and answer both parts ASSIGNMENT 5: CREATE & EXECUTE Database Trigger titled 'stock update'...