简体   繁体   中英

How to create stored procedure in mysql workbench?

I know Microsoft sql server and I think this codes doesn't contain an error. But Mysql thow an exeption which I Couldn't undestant. Is anybody can explain it for me and please,give me mysql function,view,stored procedure examples website name

CREATE PROCEDURE spInsertEmployee
(
 Employee_Name nvarchar(20),
 Employee_Surname nvarchar(20),
 Department_Name nvarchar(20)
)
BEGIN
declare Department_Id int; /*error*/
select Id into Department_Id from tblDepartment where      tblDepartment.Department_Name=Department_Name;
insert into tblVeri(Employee_Name,Employee_Surname,Department_Id)     values(Employee_Name,Employee_Surname,Department_Id);
END /*error*/

You must define IN for the parameters.

DELIMITER $$

CREATE PROCEDURE spInsertEmployee 
(
IN Employee_Name nvarchar(20), 
IN Employee_Surname nvarchar(20), 
IN Department_Name nvarchar(20)
)
BEGIN
declare Department_Id INT;

select Id into Department_Id from tblDepartment WHERE tblDepartment.Department_Name=Department_Name;
insert into tblVeri(Employee_Name,Employee_Surname,Department_Id)     VALUES(Employee_Name,Employee_Surname,Department_Id);

END;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM