Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic question about a procedure

Status
Not open for further replies.

kyru

Programmer
Jan 17, 2009
45
ES
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?
 
Unbalanced paranthesis in the IF statement.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top