DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `srt`.`bufferPool_get`() RETURNS int(11) NOT DETERMINISTIC READS SQL DATA BEGIN /** * Devuelve el primer bufferFk de la tabla srt.bufferPool * * @return Identificador de vn.buffer * */ DECLARE vBufferFk INT; DECLARE vBufferPoolFk INT; SELECT MIN(id) INTO vBufferPoolFk FROM srt.bufferPool; IF vBufferPoolFk THEN SELECT bufferFk INTO vBufferFk FROM srt.bufferPool WHERE id = vBufferPoolFk; DELETE FROM srt.bufferPool WHERE id = vBufferPoolFk; ELSE RETURN NULL; END IF; END$$ DELIMITER ;