Ahmed-Anas
Ahmed-Anas

Reputation: 5619

Can't figure out stored procedure, error at END

I was hoping you could help me out...

I do know some SQL, but I'm new to mySQL... and there's this simple query that I just can't figure out what's wrong with it:

CREATE PROCEDURE inserttoscrapbookSD
(owner1 VARCHAR(50),
poster1 VARCHAR(50),
Scrap1 VARCHAR(50),

)
BEGIN

INSERT INTO scrapbook (Owner)

VALUES(owner1)

END

I know there are a lot of variables being passed, but just using one variable at the moment because if it works for one, it'll work for all. I tried with and without a semicolon ( ; ) at the end of END and VALUES(owner1) but no luck. It says:

#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 ') BEGIN INSERT INTO scrapbook (Owner) VALUES(owner1) END' at line 6

Upvotes: 1

Views: 2000

Answers (2)

Bohemian
Bohemian

Reputation: 425083

Your problem is you need to change the delimiter while you define the stored proc, which allows you to use semicolons ; within your stored proc code without finishing the create command.

Try this:

delimiter //

CREATE PROCEDURE inserttoscrapbookSD (
    owner1 VARCHAR(50),
    poster1 VARCHAR(50),
    Scrap1 VARCHAR(50)
)
BEGIN

INSERT INTO scrapbook (Owner)

VALUES(owner1);

END
//

delimiter ;

Upvotes: 5

dalevross
dalevross

Reputation: 522

Try removing the comma after the last parameter

Upvotes: 3

Related Questions