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