Stored procedures and cursors in MySQL

Source: Internet
Author: User

--Mysql stored procedure/*set @result = 0;create Procedure Login (--definition parameters, with in, out, inout three types in user varchar (ten), in pass varchar (ten), out result int) BEGIN DECLARE PASSD varchar (ten);--declare declares a temporary variable, type, and then assigns a value using set.declare temporary variables can only be placed in the Begin end Area, and its scope is only in the begin end, and the variable defined by SET @ is a global variable select password into PASSD from login where username=user;if passd like pass and then  --if statement, followed by end If, like case also add end case Select ' Login Success ' as massage;set result = 1;elseselect ' login Failed ' As message;set result =0;end if;end;*/--Invoke stored procedure call login (' root ', ' root ', @result);--Delete stored Procedure drop procedure Login creat E procedure translate (id int) begincase idwhen 1 then select ' One ' as Trans;when 2 thenselect ' both ' as Trans;when 3 then Select ' Three ' as Trans;elseselect ' no trans ' as Trans;end case;end; There are two types of/*case usage: 1. The condition variable is in when select name, Casewhen age>10 then Xxxxxelsexxxxxxend case2. Condition variable in case select Name,case agewhen >10 then xxx else xxxxxsend case*/

 

Stored procedures and cursors in MySQL

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.