gpt4 book ai didi

mysql - 如何在mysql工作台中创建存储过程?

转载 作者:行者123 更新时间:2023-11-29 12:13:40 26 4
gpt4 key购买 nike

我知道 Microsoft sql server,并且我认为此代码不包含错误。但是Mysql抛出了一个我无法理解的异常。有人可以为我解释一下吗请给我mysql函数、 View 、存储过程示例网站名称

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;

关于mysql - 如何在mysql工作台中创建存储过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30236041/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com