Monday, 5 November 2012
koding program stored dan function
DELIMITER $$
DROP FUNCTION IF EXISTS `toko_dbc110091`.`getKodepenjualan`$$
CREATE FUNCTION `toko_dbc110091`.`getKodepenjualan`(vTgl_pinjam DATETIME)
RETURNS VARCHAR(10)
DETERMINISTIC
BEGIN
DECLARE vthn CHAR(2);
DECLARE vbln CHAR(2);
DECLARE vtgl CHAR(2);
DECLARE vUrut INT;
SET vthn=SUBSTR(vTgl_pinjam,3,4);
SET vbln=SUBSTR(vTgl_pinjam,6,6);
SET vtgl=SUBSTR(vTgl_pinjam,9,9);
SELECT IFNULL (MAX(CAST(SUBSTR(Kode_Penjualan, 4, 5) AS UNSIGNED)),0)
FROM detail_penjualan
WHERE vtgl_pinjam LIKE CONCAT (vthn, vbln, vtgl, '%')INTO vUrut;
RETURN CONCAT (vthn, vbln,vtgl, vUrut+1);
END$$
DELIMITER ;
Labels:
SQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment