delimiter //
drop function if exists getLastTerm//
create function getLastTerm()
    RETURNS varchar(20)
    DETERMINISTIC
BEGIN
    DECLARE str varchar(20);
    select nounvalue into str from sys_noun where NOUNITEM = 'TERM';
    RETURN str;
END //

delimiter ;