Error: CREATE TRIGGER attendance_trigger_vss_10_2021 AFTER INSERT ON deviceLogs_10_2021 FOR EACH ROW BEGIN DECLARE mon INT; DECLARE d VARCHAR(7); DECLARE hou VARCHAR(50); DECLARE minu VARCHAR(50); DECLARE sec VARCHAR(50); DECLARE y INT; DECLARE ext VARCHAR(7); DECLARE final VARCHAR(7); DECLARE timea VARCHAR(255); DECLARE teachID INT; DECLARE checkk VARCHAR(100); SET mon = (SELECT MONTH(new.LogDate)); SET d = (SELECT DAY(new.LogDate)); SET y = (SELECT YEAR(new.LogDate)); SET hou = (SELECT TIME(new.LogDate)); IF new.DeviceId = 4 THEN SELECT COUNT(teacherID) INTO teachID FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and a_year = y; IF teachID = 0 THEN IF d = 1 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a1,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a1,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 2 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a2,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a2,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 3 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a3,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a3,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 4 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a4,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a4,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 5 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a5,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a5,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 6 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a6,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a6,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 7 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a7,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a7,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 8 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a8,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a8,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 9 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a9,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a9,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 10 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a10,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a10,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 11 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a11,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a11,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 12 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a12,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a12,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 13 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a13,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a13,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 14 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a14,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a14,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 15 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a15,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a15,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 16 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a16,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a16,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 17 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a17,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a17,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 18 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a18,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a18,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 19 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a19,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a19,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 20 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a20,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a20,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 21 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a21,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a21,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 22 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a22,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a22,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 23 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a23,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a23,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 24 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a24,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a24,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 25 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a25,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a25,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 26 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a26,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a26,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 27 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a27,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a27,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 28 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a28,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a28,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 29 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a29,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a29,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 30 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a30,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a30,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 31 THEN INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a31,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a31,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_vss.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; END IF; IF teachID > 0 THEN IF d = 1 THEN SELECT a1 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a1 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a1 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a1 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 2 THEN SELECT a2 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a2 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a2 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a2 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 3 THEN SELECT a3 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a3 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a3 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a3 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 4 THEN SELECT a4 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a4 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a4 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a4 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 5 THEN SELECT a5 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a5 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a5 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a5 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 6 THEN SELECT a6 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a6 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a6 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a6 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 7 THEN SELECT a7 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a7 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a7 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a7 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 8 THEN SELECT a8 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a8 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a8 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a8 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 9 THEN SELECT a9 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a9 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a9 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a9 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 10 THEN SELECT a10 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a10 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a10 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a10 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 11 THEN SELECT a11 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a11 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a11 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a11 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 12 THEN SELECT a12 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a12 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a12 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a12 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 13 THEN SELECT a13 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a13 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a13 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a13 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 14 THEN SELECT a14 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a14 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a14 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a14 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 15 THEN SELECT a15 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a15 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a15 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a15 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 16 THEN SELECT a16 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a16 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a16 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a16 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 17 THEN SELECT a17 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a17 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a17 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a17 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 18 THEN SELECT a18 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a18 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a18 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a18 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 19 THEN SELECT a19 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a19 = hou WHERE teacherID = new.userID and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a19 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a19 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 20 THEN SELECT a20 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a20 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a20 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a20 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 21 THEN SELECT a21 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a21 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a21 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a21 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 22 THEN SELECT a22 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a22 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a22 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a22 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 23 THEN SELECT a23 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a23 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a23 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a23 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 24 THEN SELECT a24 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a24 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a24 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a24 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 25 THEN SELECT a25 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a25 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a25 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a25 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 26 THEN SELECT a26 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a26 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a26 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a26 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 27 THEN SELECT a27 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a27 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a27 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a27 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 28 THEN SELECT a28 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a28 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a28 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a28 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 29 THEN SELECT a29 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a29 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a29 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a29 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 30 THEN SELECT a30 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a30 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a30 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a30 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 31 THEN SELECT a31 INTO checkk FROM skoolroo_vss.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_vss.tattendance SET a31 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_vss.tattendance SET a31 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_vss.tattendance SET a31 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; END IF; END IF; END
Trigger already existsError: CREATE TRIGGER attendance_trigger_svis_10_2021 AFTER INSERT ON deviceLogs_10_2021 FOR EACH ROW BEGIN DECLARE mon INT; DECLARE d VARCHAR(7); DECLARE hou VARCHAR(50); DECLARE minu VARCHAR(50); DECLARE sec VARCHAR(50); DECLARE y INT; DECLARE ext VARCHAR(7); DECLARE final VARCHAR(7); DECLARE timea VARCHAR(255); DECLARE teachID INT; DECLARE checkk VARCHAR(100); SET mon = (SELECT MONTH(new.LogDate)); SET d = (SELECT DAY(new.LogDate)); SET y = (SELECT YEAR(new.LogDate)); SET hou = (SELECT TIME(new.LogDate)); IF new.DeviceId = 2 THEN SELECT COUNT(teacherID) INTO teachID FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and a_year = y; IF teachID = 0 THEN IF d = 1 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a1,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a1,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 2 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a2,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a2,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 3 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a3,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a3,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 4 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a4,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a4,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 5 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a5,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a5,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 6 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a6,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a6,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 7 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a7,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a7,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 8 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a8,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a8,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 9 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a9,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a9,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 10 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a10,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a10,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 11 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a11,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a11,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 12 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a12,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a12,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 13 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a13,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a13,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 14 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a14,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a14,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 15 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a15,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a15,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 16 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a16,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a16,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 17 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a17,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a17,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 18 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a18,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a18,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 19 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a19,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a19,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 20 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a20,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a20,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 21 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a21,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a21,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 22 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a22,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a22,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 23 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a23,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a23,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 24 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a24,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a24,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 25 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a25,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a25,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 26 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a26,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a26,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 27 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a27,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a27,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 28 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a28,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a28,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 29 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a29,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a29,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 30 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a30,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a30,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; IF d = 31 THEN INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a31,a_year) VALUES(new.UserId,'Teacher',mon,'in',hou,y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a31,a_year) VALUES(new.UserId,'Teacher',mon,'status','P',y); INSERT INTO skoolroo_svis.tattendance (teacherID,usertype,monthyear,type,a_year) VALUES(new.UserId,'Teacher',mon,'out',y); END IF; END IF; IF teachID > 0 THEN IF d = 1 THEN SELECT a1 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a1 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a1 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a1 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 2 THEN SELECT a2 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a2 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a2 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a2 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 3 THEN SELECT a3 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a3 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a3 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a3 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 4 THEN SELECT a4 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a4 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a4 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a4 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 5 THEN SELECT a5 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a5 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a5 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a5 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 6 THEN SELECT a6 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a6 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a6 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a6 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 7 THEN SELECT a7 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a7 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a7 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a7 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 8 THEN SELECT a8 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a8 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a8 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a8 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 9 THEN SELECT a9 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a9 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a9 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a9 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 10 THEN SELECT a10 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a10 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a10 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a10 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 11 THEN SELECT a11 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a11 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a11 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a11 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 12 THEN SELECT a12 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a12 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a12 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a12 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 13 THEN SELECT a13 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a13 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a13 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a13 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 14 THEN SELECT a14 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a14 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a14 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a14 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 15 THEN SELECT a15 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a15 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a15 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a15 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 16 THEN SELECT a16 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a16 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a16 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a16 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 17 THEN SELECT a17 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a17 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a17 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a17 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 18 THEN SELECT a18 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a18 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a18 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a18 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 19 THEN SELECT a19 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a19 = hou WHERE teacherID = new.userID and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a19 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a19 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 20 THEN SELECT a20 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a20 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a20 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a20 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 21 THEN SELECT a21 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a21 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a21 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a21 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 22 THEN SELECT a22 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a22 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a22 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a22 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 23 THEN SELECT a23 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a23 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a23 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a23 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 24 THEN SELECT a24 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a24 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a24 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a24 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 25 THEN SELECT a25 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a25 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a25 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a25 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 26 THEN SELECT a26 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a26 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a26 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a26 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 27 THEN SELECT a27 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a27 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a27 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a27 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 28 THEN SELECT a28 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a28 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a28 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a28 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 29 THEN SELECT a29 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a29 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a29 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a29 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 30 THEN SELECT a30 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a30 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a30 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a30 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; IF d = 31 THEN SELECT a31 INTO checkk FROM skoolroo_svis.tattendance WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; IF checkk IS NULL THEN UPDATE skoolroo_svis.tattendance SET a31 = hou WHERE teacherID = new.UserId and monthyear = mon and type='in' and a_year = y; UPDATE skoolroo_svis.tattendance SET a31 = 'P' WHERE teacherID = new.UserId and monthyear = mon and type='status' and a_year = y; END IF; IF checkk IS NOT NULL THEN UPDATE skoolroo_svis.tattendance SET a31 = hou WHERE teacherID = new.UserId and monthyear = mon and type='out' and a_year = y; END IF; END IF; END IF; END IF; END
Trigger already exists