MySQL Storage process

Source: Internet
Author: User
Create a process
create procedure demo(in par int)//in out inout   参数名字 参数类型 beginset @a = 123;//会话变量 对当前会话有效,全局的变量declare a int;//用普通变量要声明类型,只对一个作用域有用declare a int default 5;//直接声明并赋值set a = 123;//普通变量if a = 123 thenend if;if a = 12345 then……else……end if;case awhen 1 then  select xx;when 2 then select bb;end case;while a < 3000 do insert into demo(a);set v = v+1;//条件一定要有自增运算,不然会一直whileend whild;end;
Loop
loop没有条件, 所以需要用If判断 然后用leave 离开定义的loop标签loop_label:loopif xxx then leave loop_label;end if;end loop;
ITERATE 类型C中的continue;create procedure error()begindeclare exit handler for 1216//如果发生1216错误,就执行插入error_tabinsert into  error_tab (xxx);end;

MySQL Storage process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.