我是mysql的新手。插入触发器mysql后怎么办?
table parent (gaji_bulanan) inserting from my sistem
----------------------------------------------------------------------------
id_gajibul|kd_gajibul|jenis_gaji|nip|massa|nama|bulan|tahun|upahperbulan|lem1|
----------------------------------------------------------------------------
1|KD.1|B|100|M1|enggar|oktober|2017|100000|1|
2|KD.2|B|100|M2|enggar|desember|2017|150000|2|
----------------------------------------------------------------------------
the result is i wanted in another table (gaji_bulanan_b) from the trigger function like this
---------------------------------------------------------------------------
id_gajibul|kd_gajibul|jenis_gaji|nip|massa|nama|bulan|tahun|upahperbulan|lem1
----------------------------------------------------------------------------
3|KD.2|B||100|B|enggar|desember|2017|250000|3|
这是我的触发器的例子
DELIMITER $$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
TRIGGER `gaji`.`gaji_bul` AFTER INSERT
ON `gaji`.`gaji_bulanan`
FOR EACH ROW BEGIN
IF NEW.massa='M2' THEN
INSERT INTO gaji_bulanan_b(id_gajibul,kd_gajibul,jenis_gaji,nip,massa,nama,bulan,tahun,upah_per_bulan,lem1)
VALUES(NEW.id_gajibul,OLD.kd_gajibul,OLD.jenis_gaji,NEW.nip,NEW.massa='B',OLD.nama,NEW.bulan,NEW.tahun,
upah_per_bulan=NEW.upah_per_bulan+OLD.upah_per_bulan);
END IF;
END$$
DELIMITER ;
任何人都可以帮助我吗?
提前致谢
祝你好运