1
delimeter //
DROP function IF EXISTS get_seq_next//
create function get_seq_next(
IN sequence_ref_ varchar(30)
) returns int(11) unsigned
BEGIN
    DECLARE seq_val_  int(11) unsigned;
    LOCK TABLE ga_seq_tab WRITE;
    select sequence_no into seq_val_ from ga_seq_tab where sequence_ref=sequence_ref_;
    if not seq_val_ is null then
        update ga_seq_tab set sequence_no=sequence_no+1 where sequence_ref=sequence_ref_;
    end if
    UNLOCK TABLES;
    return seq_val;
END //
DELIMETER ;

I'm trying to create a function but it keeps saying I have syntax errors and I am not sure what is wrong with it

3
  • 1
    please post the error. one problem is that you've misspelled delimiter Commented Jun 13, 2012 at 20:58
  • #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN sequence_ref_ varchar(30) ) returns int(11) unsigned BEGIN DECLARE seq_va' at line 2 (I don't have the delimiter fields there when posting it as I am doing so through phpmyadmin (field that specifies it for me)) Commented Jun 14, 2012 at 12:34
  • I removed the "IN" and I got further, I guess all parameters are IN parameters in a function Commented Jun 14, 2012 at 12:44

1 Answer 1

1

Try removing the IN reserved word in the parameters list.

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

Comments

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.