MySQL Forums
Forum List  »  Spanish

Necesito ayuda para crear un procedimiento almacenado
Posted by: sebastian s
Date: August 25, 2017 05:51AM

Saludos a todos, espero que puedan ayudarme.

Estoy intentando realizar el siguiente procedimiento almacenado para registrar maquinas e ir decrementando su vida útil en el campo estado. Es una sola tabla muy sencilla que tiene los campos : ID_MAQUINA,, estado, fecha y el procedimiento tiene como parametro el ID_MAQUINA.


DELIMITER $$
CREATE DEFINER=`tablaDatosm`@`localhost` PROCEDURE `test1`(IN `nmaquina' DOUBLE)
BEGIN
declare a int; declare est int;
set a=(SELECT COUNT(ID_MAQUINA) from registro where ID_MAQUINA=nmaquina);
if (a=1) then
select 1;
ELSE
if (a=0) THEN
insert into registro VALUES(0, curdate(),'',nmaquina);
END IF;
set est=(SELECT estado from registro where ID_MAQUINA=nmaquina);
if (est<1 and est>-16) then
update MAQUINA set estado=est-1 where id_maquina= nmaquina;
END IF;
SELECT estado from registro where ID_MAQUINA=nmaquina;
END IF;
END$$
DELIMITER

al ejecutarlo:

call test1 (123);


me aparece este mensaje:

MySQL ha dicho:
#1146 - Tabla 'tablaDatos_registro.registro' no existe


¿Que podrá ser lo que está mal?

Options: ReplyQuote


Subject
Views
Written By
Posted
Necesito ayuda para crear un procedimiento almacenado
800
August 25, 2017 05:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.