USE `inventory`;
DROP FUNCTION IF EXISTS `generatorKodePersediaan`;
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `generatorKodePersediaan`(`PKELOMPOK` CHAR(10), `PBARANG` INT) RETURNS char(16) CHARSET latin1
    DETERMINISTIC
BEGIN
	INSERT INTO kode_barang_psedia (KELOMPOK,BARANG)VALUES(PKELOMPOK,PBARANG);
	RETURN CONCAT(PKELOMPOK, LPAD(LAST_INSERT_ID(), 6, '0'));
END//
DELIMITER ;