Hello everyone, I'm rather new to MySQL so I've a question in a basic thing that is that the way I guess a procedure should be defined is giving an error in the DECLARE _valorOld VARCHAR(100); about an unexpected if and even an unexpected end even if I eliminate the if section.
The code is the following:
CREATE DEFINER=`definer`@`%` PROCEDURE `newvalue`()
_idusuario INTEGER(11),
_tabla VARCHAR(45),
_idt INTEGER(11),
_nombre VARCHAR(45),
_valor VARCHAR(100)
)
BEGIN
DECLARE _valorOld VARCHAR(100);
SELECT valor INTO _valorOld FROM myvalues WHERE idt=_idt AND tabla=_tabla AND nombre=_nombre ;
IF ((_valorOld IS NOT NULL) THEN
INSERT INTO myvalues (idusuario,tabla,idt,nombre,valor) VALUES (_idusuario,_tabla,_idt,_nombre,_valor);
END IF;
END
I don't see any clear difference in the examples of a procedure that I've seen around the net, som, does anyone know what can be failing?
The code is the following:
CREATE DEFINER=`definer`@`%` PROCEDURE `newvalue`()
_idusuario INTEGER(11),
_tabla VARCHAR(45),
_idt INTEGER(11),
_nombre VARCHAR(45),
_valor VARCHAR(100)
)
BEGIN
DECLARE _valorOld VARCHAR(100);
SELECT valor INTO _valorOld FROM myvalues WHERE idt=_idt AND tabla=_tabla AND nombre=_nombre ;
IF ((_valorOld IS NOT NULL) THEN
INSERT INTO myvalues (idusuario,tabla,idt,nombre,valor) VALUES (_idusuario,_tabla,_idt,_nombre,_valor);
END IF;
END
I don't see any clear difference in the examples of a procedure that I've seen around the net, som, does anyone know what can be failing?