I want a SQL procedure / function to solve the below mentioned problem:
I have 2 tables - Table A and table B.
When a value of flag column changes in table A, a record should be inserted in table B with the same values of name and number from table A.
How can I achieve this?
You can achieve this by using triggers.
You can write triggers that fire whenever and INSERT, UPDATE, or DELETE operation is performed on a particular table or view.
General Syntax:
CREATE TRIGGER WRITE_TRIGGER_NAME_HERE
BEFORE UPDATE ON TABLE_A
FOR EACH ROW
BEGIN
WRITE_INSERT_STATEMENT_HERE_FOR_TABLE_B
END;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.