Home > Database > Mysql Tutorial > body text

mysql sql stored procedure condition definition and processing

黄舟
Release: 2016-12-24 17:53:48
Original
1580 people have browsed it

1. Condition definition

DECLARE condition_name CONDITION FOR condition_vale

condition_value:

              sqlstate[value] sqldata_value |mysql tutorial_error_code

2. Condition processing

DECLARE htype HANDLER FOR cond_ value[...] sp_statement

handtype_value :

  sqlstate [value] saltate_value

|contentname

|sqlwarning

|not found

|sqlexeeption

|mysql_erroe_code

The above is the syntax, let’s talk about it through examples

mysq l>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 into actor(id)values(201)

->sex @x=2;

insert into actor(id)values(202)

->set @ x=3;

->end

->$$

query ok, 0 rows affected (0.00 sec)

mysql->delimiter;

mysql>call actor_insert();

error 1062 (23000):duplicate entyr 202 from key primary

mysql->select @x;

@x

201

1row in set (0.00 sec)

As can be seen from the above, when the primary key is duplicated, it will not Do other operations

The above is the content of mysql sql stored procedure condition definition and processing. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template