What's wrong with this MySQL CREATE FUNCTION?

1

What is wrong with this create function? I can not figure it out. Already the error in the first line.

CREATE FUNCTION SEQ_NEXT_VAL() 
RETURNS INT 
DETERMINISTIC
BEGIN
  DECLARE retorno INT;

  SELECT MAX(IDE_ERROR) INTO retorno FROM ERROR_LOGGING;
  IF retorno = NULL THEN
    retorno = 1;
  ELSE
    retorno = retorno + 1;
  END IF;

  RETURN retorno;
END;
    
asked by anonymous 01.12.2017 / 16:56

1 answer

0

Missing set of variables:

DROP FUNCTION IF EXISTS SEQ_NEXT_VAL;
DELIMITER |
CREATE FUNCTION SEQ_NEXT_VAL() 
RETURNS INT 
DETERMINISTIC
BEGIN
  DECLARE retorno INT;

  SELECT MAX(IDE_ERROR) INTO retorno FROM ERROR_LOGGING;
  IF retorno = NULL THEN
    SET retorno = 1;
  ELSE
    SET retorno = retorno + 1;
  END IF;

  RETURN retorno;
END
|
DELIMITER ;
    
01.12.2017 / 17:05