存储过程有关问题

存储过程问题

mysql> create procedure pro() begin end;

Query OK, 0 rows affected (0.00 sec)

可以成功执行,begin end 之间什么都没有

在里面添加操作语句

mysql> create procedure pro() begin select * from person; end;

ERROR 1064 (42000): 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 ‘selec

t * from person’ at line 1

ERROR 1064 (42000): 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 ‘end’

at line 1

反正begin 里面填入什么东西都无法执行通过。什么问题啊,纠结。。

mysql> create procedure pro() begin

  -> insert into person values(1,’aname’,2); end;

ERROR 1064 (42000): 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 ‘inser

t into person values(1,’aname’,2)’ at line 2

ERROR 1064 (42000): 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 ‘end’

at line 1

person 表结构: (id int , name varcha(10), age int);



你少了 delimiter 语句。这样当你的MYSQL命令行工具看到 第一个;就提交了。

delimter //

create procedure pro() begin select * from person; end//

delimiter ;

参考一下手册中的例子。

MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html

存储过程有关问题

相关文章:

你感兴趣的文章:

标签云: