Mysql-Stored Procedure Example

Source: Internet
Author: User
Tags stored procedure example

Recently need to use MySQL, no patience from beginning to end, slowly understand, need what direct Baidu, direct understanding, from the actual combat learning.

Take a look at an example of a MySQL stored procedure:

CREATE PROCEDUREPlogin (P_usernameChar( the), P_passwordChar( +), P_ipChar( -), P_logintimedatetime) Label_proc:BEGIN         DECLAREV_uid Mediumint (8); DECLAREV_realpasswordChar( +); DECLAREV_nicknamevarchar( -); DECLAREV_oltimesmallint(6); SELECTU.uid, U.password, F.nickname, U.oltime intoV_uid, V_realpassword, V_nickname, V_oltime fromCdb_members uINNER JOINCdb_memberfields F onF.uid=U.uidWHEREU.username=P_username; IF(V_uid is NULL) Then        SELECT 2  asErrorCode;    LEAVE Label_proc; END IF; IF(P_password<>V_realpassword) Then        SELECT 3  asErrorCode;    LEAVE Label_proc; END IF; UPDATEIpsp_userexpandsSETLastloginip=P_IP, Lastlogintime=P_logintimeWHEREUid=V_uid; SELECT 0  asErrorCode, V_uid asUID, V_nickname asNickname, V_oltime asOltime;ENDLabel_proc//

The invocation example is call Plogin (' parameter 1 ', ' Parameter 2 ', ' Parameter 3 ', ' parameter 4 ');

Mysql-Stored Procedure Example

Related Article

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.