vibhor vaish vibhor vaish - 7 months ago 22
SQL Question

#1064 - You have an error in your SQL syntax

I already have a table employee with columns name(String),id(int),age(int).
I can't figure out where the syntax is wrong?

CREATE PROCEDURE recins (
name1 IN employee.name%type ,
id1 IN employee.id%type ,
age1 IN employee.age%type
) AS
BEGIN
INSERT INTO employee VALUES(name1,id1,age1);
END;

Answer
create table employee2
(
    name varchar(100) not null,
    id int not null,
    age int not null
);


DELIMITER $$
CREATE PROCEDURE recins (
    IN name1 varchar(100),
    IN id1 int,
    IN age1 int
)
BEGIN
    INSERT INTO employee2 (name,id,age) VALUES(name1,id1,age1);
END $$
DELIMITER ;

-- test:
call recins('a',1,2);

delimiter is a special wrapper for stored procs, events, functions. Delimiter ; at the end of the stored proc sets it back to the normal/default delimiter of a semi-colon.

The above was tested.