USE `sakti`;
DROP FUNCTION IF EXISTS `getDetailBarang`;
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `getDetailBarang`(`PHEADER` INT) RETURNS longtext CHARSET latin1
    DETERMINISTIC
BEGIN
	DECLARE VTEXT LONGTEXT;
	
	SELECT
		GROUP_CONCAT(CONCAT(
			IF(s.KODE_BARANG IS NULL,"",s.KODE_BARANG), "|"
			, s.HARGA_SATUAN, "|"
			, s.JUMLAH_BARANG, "|"
			, s.KODE_UAKPB
		) SEPARATOR "\r\n") INTO VTEXT
	FROM sakti.sakti_barang_detail s
	WHERE s.HEADER = PHEADER;
	
	RETURN VTEXT;
END//
DELIMITER ;