MySQL is really not as flexible as SQL Server
Stored Procedure considerations:
1.declare declarations in turn
DECLARE Myaccountid VARCHAR (36);
DECLARE Balance DECIMAL (2), DEFAULT 0.00;
DECLARE Operator VARCHAR ($) DEFAULT ' 168a65d2-7ff7-4865-84ef-c41560f4d8d5 ';
DECLARE TypeName VARCHAR (200);
If there is a default value, if you want to assign a value, after the variable is all declared, use the set
SET TypeName = (
Case Type
When 1 Then
Recharge
ELSE
' Debit '
END
);
Try not to set, then declare, there will be inexplicable mistakes
2. In a large segment of the SQL statement (SELECT * from ...., insert INTO ...). ), if you want to assign a value to a variable with select
SELECT (
Case Type
When 1 Then
Balance + Money
When 0 Then
Balance-money
ELSE
0
END
) into Balance;
Here I use set to assign value how to make all error ...
You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near "at line 186
Set execution is not wrong, put it here ..... Try again and again, only to find the reason, really his mother pit than AH.
--Determine if the account funds are abnormal
IF Type <> 3 Then
SELECT
' 2 ';
ELSEIF Type = 3 Then
SELECT
' 3 ';
ELSE
SELECT
' 1 ';
END
IF;
MySQL stored procedures, the syntax of the dead