1

I forget put delimiter directive, some semicolon and was using tsl syntax like [select variable = field] that is not valid in mysql.
Mysql error when you use tsl syntax is [not allowed to return a result set from a function] and dont help much.
@AndreKR point all of it to me, thanks.
Im using mysqlworkbench 5.2.30 CE. The work 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 ;
1
  • @Mitch Wheat The version is [Server version: 5.1.53-community MySQL Community Server (GPL)] Commented Nov 8, 2011 at 23:58

1 Answer 1

0

Since the DECLARE workval bigint(20); line is the first one with a semicolon at the end, I suspect you forgot to change the delimiter before inputting the function code (though this depends on the client you're using).

Try changing your code to:

DELIMITER #
CREATE FUNCTION nextval (seq_name varchar(100))  

...

END#
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot, its solve that problem. I have a new problem now and edited question with details. I did the correction you pointed to me too.
Please open a new question if you have another problem. (To which the solution has something to do with the word "into", I guess.)
Im sory, i tried declare another variable do transfer value and return but its dont work, there is the ask with detail: stackoverflow.com/questions/8073404/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.