-- --------------------------------------------------------
-- Server OS:                    Linux
-- HeidiSQL Version:             12.0.0.6468
-- --------------------------------------------------------


USE `generator`;

-- Dumping structure for table generator.no_kegiatan_laundry
CREATE TABLE IF NOT EXISTS `no_kegiatan_laundry` (
  `RUANGAN` char(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `TANGGAL` date NOT NULL,
  `NOMOR` smallint NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`RUANGAN`,`TANGGAL`,`NOMOR`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- Data exporting was unselected.

-- Dumping structure for function generator.generateNoKegiatanLaundry
DELIMITER //
CREATE FUNCTION `generateNoKegiatanLaundry`(
	`PRUANGAN` CHAR(10),
	`PTANGGAL` DATE
) RETURNS varchar(19) CHARSET latin1
    DETERMINISTIC
BEGIN
	INSERT INTO generator.no_kegiatan_laundry(RUANGAN, TANGGAL)
	VALUES(PRUANGAN, PTANGGAL);
		
	RETURN CONCAT(PRUANGAN, DATE_FORMAT(PTANGGAL, '%y%m%d'), LPAD(LAST_INSERT_ID(), 4, '0'));
END//
DELIMITER ;

