这个mysql存储过程哪里有错,高手指教
这个mysql存储过程哪里有错,高手指教
create procedure sp_insert_depart(
in dep_name varchar(50),
in dep_memo varchar(50),
out Result int
)
BEGIN
INSERT INTO tbl_depart(departid,departname,departmemo) values (null,dep_name,dep_memo);
set Result = LAST_INSERT_ID();
END;
SQL 查询:
CREATE PROCEDURE sp_insert_depart( IN dep_name varchar( 50 ) , IN dep_memo varchar( 50 ) , out Result int ) BEGIN INSERT INTO tbl_depart( departid, departname, departmemo )
VALUES (
NULL , dep_name, dep_memo
);
MySQL 返回:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
------解决方案--------------------delimiter //
create procedure sp_insert_depart(
in dep_name varchar(50),
in dep_memo varchar(50),
out Result int
)
BEGIN
INSERT INTO tbl_depart(departid,departname,departmemo) values (null,dep_name,dep_memo);
set Result = LAST_INSERT_ID();
END;
//
------解决方案--------------------
如果是在MYSQL命令行下输入:
delimiter $$
create procedure sp_insert_depart(
in dep_name varchar(50),
in dep_memo varchar(50),
out Result int
)
BEGIN
INSERT INTO tbl_depart(departid,departname,departmemo) values (null,dep_name,dep_memo);
set Result = LAST_INSERT_ID();
END;$$
delimiter ;