DECLARE ....条件不工作

时间:2014-05-26 11:45:53

标签: mysql

我尝试从数据库中的MySQL documentation获取以下语句

DECLARE no_such_table CONDITION FOR SQLSTATE '42S02';

但我仍然收到以下错误:

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 'DECLARE no_such_table CONDITION FOR SQLSTATE '42S02'' at line 1
那是什么?为什么我无法得到它?

1 个答案:

答案 0 :(得分:2)

DECLARE语句只能在BEGIN ... END内使用(=存储过程,函数,触发器)。

请参阅http://dev.mysql.com/doc/refman/5.0/en/declare.html