DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketWarehouseGet`(vTicketFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA BEGIN DECLARE vWarehouseFk INT; SELECT warehouseFk INTO vWarehouseFk FROM ticket WHERE id = vTicketFk; RETURN vWarehouseFk; END$$ DELIMITER ;