DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN DECLARE vIssued DATE; DECLARE vSerial VARCHAR(15); SELECT issued, ref INTO vIssued, vSerial FROM invoiceOut WHERE id = vSelf; RETURN CONCAT_WS('/' ,'invoice' ,YEAR(vIssued) ,MONTH(vIssued) ,DAY(vIssued) ,CONCAT(YEAR(vIssued), vSerial, '.pdf') ); END$$ DELIMITER ;