DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`expeditionLoading_add`(vExpeditionFk INT, vBufferFk INT) BEGIN DECLARE vMessage VARCHAR(50) DEFAULT ''; IF (SELECT COUNT(*) FROM srt.buffer WHERE id = vBufferFk) = 0 THEN SET vMessage = 'Buffer incorrecto'; END IF; IF (SELECT COUNT(*) FROM srt.expedition WHERE id = vExpeditionFk) = 0 THEN SET vMessage = 'ExpediciĆ³n no existe'; END IF; IF LENGTH(vMessage) = 0 THEN REPLACE srt.expeditionLoading (expeditionFk, bufferFk) VALUES (vExpeditionFk, vBufferFk); SET vMessage = 'Registro aƱadido'; END IF; SELECT vMessage; END$$ DELIMITER ;