DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `PTALLN_NEW`(`in_pta_id` INT) RETURNS varchar(128) CHARSET utf8mb4
    READS SQL DATA
    DETERMINISTIC
BEGIN
DECLARE out_pta_pretty VARCHAR(128);
SELECT CONCAT(pta_leerjr, pta_target, '.', subj_abbrev, '/',IF(inhaalregime = 0, 'TP', 'per'), pta_tp, ' ', stvt, IFNULL(shortdesc, ''), IF(pta_tp = 0, CONCAT(' (TP3 ', pta_leerjr - 1, pta_target), '')) INTO out_pta_pretty FROM ptas JOIN kldv.subj USING (subj_id) WHERE pta_id = in_pta_id;
RETURN out_pta_pretty;
END$$

DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `PTA_NEW`(`in_pta_id` INT) RETURNS varchar(128) CHARSET utf8mb4
    READS SQL DATA
    DETERMINISTIC
BEGIN
DECLARE out_pta_pretty VARCHAR(128);
SELECT CONCAT(pta_leerjr, pta_target, '.', subj_abbrev, '/',IF(inhaalregime = 0, 'TP', 'per'), pta_tp, ' ', stvt, IFNULL(shortdesc, ''), IF(toetsversie='', '', CONCAT(' (versie ', toetsversie,')'))) INTO out_pta_pretty FROM ptas JOIN kldv.subj USING (subj_id) WHERE pta_id = in_pta_id;
RETURN out_pta_pretty;
END$$
DELIMITER ;DELIMITER ;
