Reputation: 1
I'm trying to write a stored procedure to insert data into a table.
The procedure which I wrote is:
CREATE PROCEDURE insrtem (IN x int(3),IN y varchar(3))
BEGIN
insert into emp (empid,empname) values (x,y);
END;
but it doesn't work.
What's the correct syntax?
Upvotes: 0
Views: 200
Reputation: 1269693
In MySQL, you often need a delimiter
statement, so that is my first guess:
DELIMITER $$
CREATE PROCEDURE insrtem (IN in_x signed, IN in_y varchar(3))
BEGIN
insert into emp (empid, empname)
values (in_x, in_y);
END;
DELIMITER ;
Notice I changed the names of the parameters to have an in
prefix. This helps distinguish the parameters from columns in the table.
Upvotes: 2