Syntax error: Problem with variable inside the IF

0

My code:

    DELIMITER //
    CREATE FUNCTION f_desc (in_preco int)
    RETURNS INT
    BEGIN
    DECLARE fim_preco INT;
    IF in_preco >= 100 THEN
        -- aqui
        fim_preco := format(10 * in_preco/100, 2);
    ELSEIF in_preco >= 200 THEN
        -- aqui
        fim_preco := format(20 * in_preco/100, 2);
    ELSE
        -- aqui
        fim_preco := in_preco;
    END IF;
    RETURN(fim_preco);
    END;
    //

Where I checked it turns red and displays:

  

syntax error unexpected end_preco

I really do not understand why, since the variable was created ..

    
asked by anonymous 31.07.2018 / 23:07

1 answer

1

Use SET fim_preco = blablabla instead of fim_preco := blablabla .

See here compiling in sqlfiddle.

    
31.07.2018 / 23:15