Skip to content

Instantly share code, notes, and snippets.

@cpamungkas
Created June 21, 2012 09:15
Show Gist options
  • Save cpamungkas/2964781 to your computer and use it in GitHub Desktop.
Save cpamungkas/2964781 to your computer and use it in GitHub Desktop.
Example Trigger Before Insert
DELIMITER $$
DROP TRIGGER /*!50032 IF EXISTS */ `ujicobadb`.`tr_auto_jual`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `tr_auto_jual` BEFORE INSERT ON `tx_jualan`
FOR EACH ROW BEGIN
UPDATE tm_produk SET nQtyJual = (nQtyJual - new.nQty) WHERE sIdProduk=new.sIdProdukfk ;
END;
$$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment