Declare variable syntax invalid in MySQL?

I'm trying to run a simple code that had already run on another machine and worked perfectly, now that I try to run it on my machine I get the syntax error.

I run it in Workbench Version 8.0

delimiter $$
create function funcion_mul(P_NUM2 INT)
returns INT
begin
    DECLARE declare valor_final INT default 0;
    RETURN valor_final;
END;
$$
delimiter ;

"DECLARE" is no valid at this position for this server version, expecting :

¿Qué es lo que está mal?

Thanks

Upvotes: 0

Views: 44

Answers (1)

azbarcea
azbarcea

Reputation: 3657

What about removing the declare duplication ?

delimiter $$
CREATE FUNCTION funcion_mul(P_NUM2 INT)
RETURNS INT
BEGIN
    DECLARE valor_final INT default 0;
    RETURN valor_final;
END;
$$
delimiter;

Upvotes: 1

Related Questions