我有一个问题,当我插入表temp时,表transaksi没有更新 这是触发器代码,感谢您的合作
DROP TRIGGER IF EXISTS `tr1` ;
CREATE DEFINER = `root`@`localhost` TRIGGER `tr1` AFTER UPDATE ON `temp` FOR EACH ROW BEGIN DECLARE user varchar( 50 ) ;
DECLARE barang varchar( 100 ) ;
DECLARE hg int( 10 ) ;
DECLARE st int( 10 ) ;
SELECT username(
)
INTO user;
SELECT nama_produk(
)
INTO barang;
SELECT harga(
)
INTO hg;
INSERT INTO transaksi( id, username, barang_pesan, total )
VALUES (
"", user, barang, harga
);
END
答案 0 :(得分:0)
您必须使用与after insert
事件
CREATE DEFINER = `root`@`localhost` TRIGGER `tr1` AFTER INSERT ON `temp` ...