USE `sakti`;
DROP FUNCTION IF EXISTS `getDataCoa`;
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `getDataCoa`(`PHEADER` INT) RETURNS longtext CHARSET latin1
    DETERMINISTIC
BEGIN
	DECLARE VTEXT LONGTEXT;
	SELECT
		GROUP_CONCAT(CONCAT(
			s.KODE_COA, "|"
			, s.NILAI_COA_DETAIL, "|"
			, s.NILAI_VALAS_DETAIL, "|"
			, s.VOL_SUB_OUTPUT
		) SEPARATOR "\r\n")  INTO VTEXT
	FROM sakti.sakti_coa s
	WHERE s.HEADER = PHEADER
	GROUP BY s.HEADER;
	RETURN VTEXT;
END//
DELIMITER ;