如何在mysqlworkbench中创建存储过程?

How to create stored procedure in mysql workbench?

我知道 Microsoft sql 服务器,我认为这段代码没有错误。但是 Mysql 抛出了一个我无法取消的异常。有没有人可以为我解释一下 请给我 mysql 函数、视图、存储过程示例网站名称

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*/

您必须为参数定义 IN

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;