USE `inventory`;
DROP TRIGGER IF EXISTS `barang_before_insert`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_ENGINE_SUBSTITUTION';
DELIMITER //
CREATE TRIGGER `barang_before_insert` BEFORE INSERT ON `barang` FOR EACH ROW BEGIN
	IF NEW.KLP_PSEDIA != '' OR NEW.KLP_PSEDIA != '0' THEN
		SET NEW.KODE_PSEDIA = (SELECT generatorKodePersediaan(NEW.KLP_PSEDIA, NEW.ID));
	END IF;
END//
DELIMITER ;
