Below are my example queries:
"""
CREATE TABLE IF NOT EXISTS projects (
Project_ID TEXT UNIQUE,
Initial_Project_count TEXT,
Additional_Project_count TEXT,
Start_Date TEXT,
End_Date TEXT,
Total_Project_count TEXT,
Total_persons TEXT
)"""
"""
CREATE TABLE IF NOT EXISTS persons_tb(
Project_ID TEXT,
Initial_count TEXT,
Additional_count TEXT,
Total_count TEXT,
persons TEXT,
is_count_done TEXT,
count_Started_Date TEXT,
count_End_Date TEXT
)""",
"""
CREATE TRIGGER IF NOT EXISTS after_update_on_projects
AFTER UPDATE
ON projects
BEGIN
UPDATE persons_tb
SET count_Started_Date = NEW.Start_Date, count_End_Date = NEW.End_Date,
Initial_count = NEW.Initial_Project_count, Additional_count = NEW.Additional_Project_count, Total_count = NEW.Total_Project_count
WHERE Project_ID = NEW.Project_ID;
END;
""",
"""
CREATE TRIGGER IF NOT EXISTS after_update_count_pro
AFTER UPDATE
ON persons_tb
BEGIN
UPDATE projects
SET Total_persons = Total_persons + NEW.persons
WHERE Project_ID = NEW.Project_ID and NEW.is_count_done ="count done";
END;
"""
I want to update some columns on two tables with using triggers with after update. For example: If I update Start_Date or End_Date or Initial_Project_count on projects(table) that should be updated on persons_tb(table). And if I update persons on persons_tb(table) that should be updated on projects(table). This is working. However, the second trigger(after_update_count_pro) is also running itself automatically if first trigger doing anything. How to avoid this so the triggers will run individually.