请问一个mysql存储过程的问题,定义老是失败,谢谢
发布网友
发布时间:2022-05-05 03:14
我来回答
共3个回答
热心网友
时间:2022-04-15 03:06
没问题啊
我在实际环境测试如下:
mysql> create table tb_name(stuId int auto_increment primary key,_name varchar(20),_age int);
Query OK, 0 rows affected (0.01 sec)
mysql> desc tb_name;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| stuId | int(11) | NO | PRI | NULL | auto_increment |
| _name | varchar(20) | YES | | NULL | |
| _age | int(11) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
3 rows in set (0.02 sec)
mysql> delimiter //
mysql> create procere insert_Student (_name varchar(50),_age int ,out _id int)
-> begin
-> insert into tb_name value(null,_name,_age);
-> select max(stuId) into _id from tb_name;
-> end;
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql> call insert_Student('aa',10,@id);
Query OK, 0 rows affected (0.00 sec)
mysql> select @id;
+------+
| @id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
mysql> select * from tb_name;
+-------+-------+------+
| stuId | _name | _age |
+-------+-------+------+
| 1 | aa | 10 |
+-------+-------+------+
1 row in set (0.00 sec)
mysql>
热心网友
时间:2022-04-15 04:24
create procere insert_Student (_name varchar(50),_age int ,out _id int)
---create procere insert_Student (in _name varchar(50),in _age int ,out _id int)
----------------------------------------------
喔,是不是结束符的原因
delimiter $$
create procere insert_Student (in _name varchar(50),in _age int ,out _id int)
begin
insert into _student value(null,_name,_age);
select max(stuId) into _id from _student;
end $$
热心网友
时间:2022-04-15 05:59
错误很简单啊,就是你把values写成value了