最近在寫,防痴呆,筆記一下
DELIMITER $$
DROP TRIGGER IF EXISTS `teach`.`tb_bid_ins`$$
CREATE
TRIGGER `tb_bid_ins` AFTER INSERT ON `tb_bid`
FOR EACH ROW BEGIN
DECLARE field_serno INT(10) DEFAULT NEW.serno;
DECLARE field_user_id INT(10) DEFAULT NEW.user_id;
DECLARE field_order_no INT(10) DEFAULT NEW.order_no;
DECLARE field_num INT(10) DEFAULT NEW.num;
DECLARE field_amount INT(10) DEFAULT NEW.amount;
INSERT INTO `teach`.`tb_log` (`tb_name`,`tb_field`,`tb_act`,`tb_id` ,`user_id` ,`order_no` ,`new_number`,`old_number`,`last_upd`) VALUES
('tb_bid' ,'num' ,'ins' ,field_serno,field_user_id,field_order_no,field_num ,0 ,NOW());
INSERT INTO `teach`.`tb_log` (`tb_name`,`tb_field`,`tb_act`,`tb_id` ,`user_id` ,`order_no` ,`new_number`,`old_number`,`last_upd`) VALUES
('tb_bid' ,'amount' ,'ins' ,field_serno,field_user_id,field_order_no,field_amount,0 ,NOW());
END;
$$
DELIMITER ;
沒有留言:
張貼留言