DELIMITER $$


DROP FUNCTION IF EXISTS currval$$

CREATE FUNCTION currval(v_seq_name VARCHAR(50)) RETURNS VARCHAR(50) CHARSET utf8
BEGIN  
DECLARE SEQVALUE VARCHAR(50);  
	SET SEQVALUE = '';  
	SELECT current_val INTO SEQVALUE  
	FROM sequence   
	WHERE SEQ_NAME=v_seq_name;  
RETURN SEQVALUE;  
END$$

DELIMITER ;