一、条件定义
DECLARE condition_name CONDITION FOR condition_vale
condition_value:
sqlstate[value] sqldata_value |mysql教程_error_code
二、条件处理
DECLARE htype HANDLER FOR cond_value[...] sp_statement
handtype_value:
sqlstate [value] saltate_value
|contentname
|sqlwarning
|not found
|sqlexeeption
|mysql_erroe_code
上面是语法,下面我们来通过实例说
mysql>select max(id) from ac
maxid =200;
1row in set (0.00 sec)
mysql->delimiter $$
mysql>
mysql>create procedure actor_insret()
->begin
->set @x=1;
->nsert intoactor(id)values(201)
->sex @x=2;
insert into actor(id)values(202)
->set @x=3;
->end
->$$
query ok, 0 rows afftected (0.00 sec)
mysql->delimiter;
mysql>call actor_insert();
error 1062(23000):dupllicate entyr 202 from key primary
mysql->select @x;
@x
201
1row in set (0.00 sec)
从上面可以看出当主键重复时,不会做其它作操
以上就是mysql sql存储过程条件定义与处理的内容,更多相关内容请关注PHP中文网(www.php.cn)!
本文原创发布php中文网,转载请注明出处,感谢您的尊重!