I forget put delimiter directive, some semicolon and was using tsl syntax like [choose variable = area] that's not valid in mysql.
Mysql error if you use tsl syntax is [not permitted to come back an effect set from the function] and dont help much.
@AndreKR point everything in my experience, thanks.
Im using mysqlworkbench 5.2.30 CE. The job function become:
delimiter // CREATE FUNCTION nextval (seq_name varchar(100)) RETURNS bigint(20) READS SQL DATA NOT DETERMINISTIC BEGIN DECLARE workval bigint(20); SELECT count(1) into workval FROM tip_sequence WHERE sequencename = seq_name; IF workval <> 1 THEN DELETE FROM tip_sequence WHERE sequencename = seq_name; INSERT INTO tip_sequence (sequencename, sequenceval, sequencestep) VALUES (seq_name, 1, 1); END IF; SELECT sequenceval into workval FROM tip_sequence WHERE sequencename = seq_name; UPDATE tip_sequence SET sequenceval = sequenceval + sequencestep WHERE sequencename = seq_name; RETURN workval; END// delimiter ;
DECLARE workval bigint(20); lines are the first having a semicolon in the finish, I suspect you didn't remember to alter the delimiter before typing the function code (though this is dependent around the client you are using).
Try altering your code to:
DELIMITER # CREATE FUNCTION nextval (seq_name varchar(100)) ... END#