CREATE PROCEDURE `RepairPosting`(IN RekAwal VARCHAR(20))
NOT DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE RekMax INT(20);
DECLARE KodeBaru VARCHAR(8);
DECLARE urut INT;
DECLARE RekJadi VARCHAR(20);
select max(right(kre_rekening, 5)) INTO RekMax
from data_kredit_master
where LEFT(kre_rekening, 6) = LEFT(RekAwal, 6);
SET urut = IF(RekMax IS NULL, 1, RekMax + 1);
SET KodeBaru = LPAD(urut, 5, 0);
SET RekJadi = CONCAT(LEFT(RekAwal, 6), KodeBaru);
UPDATE `data_kredit_master`
SET kre_rekening = RekJadi WHERE kre_rekening = RekAwal;
END;
Membuat Autonumbering di Mysql
Langganan:
Posting Komentar (Atom)
0 comments:
Posting Komentar