Hello Anchit,
If I understood your question correctly - SQL Triggers should satisfy your need.
If you are using Oracle Database - you can read Oracle Documentation
Oracle PL/SQL Triggers
Not every Database out there supports triggers the same way. It would be easier to give you any further advice regarding it once you've share Database vendor you are using.