First we look at a correct complete one stored procedure
① where the delimiter command is interpreted as follows: By default, delimiter is a semicolon ;. In the command-line client, if a single line of commands ends with a semicolon, the command will be executed by MySQL when the carriage returns.
This default execution of a command with a semicolon will cause the stored procedure to be created incomplete and will be executed, obviously with an error. So the delimiter command will be the default; (can also be &&,//or something). When you are finished executing
After you have finished writing a sentence, use | | End, commit execution. Finally, use the delimiter command to change back.
Local variable declarations in ②mysql can only be written in SQL statement blocks, such as functions and stored procedures, scoped to a block of statements. MSYQL does not support anonymous blocks, so it is not possible to use variables arbitrarily;
User variables are not declared to be used directly, and the scope is the current entire connection. Direct assignment with select and set where select assignment can only be assigned with ": =" because in the SELECT statement, the "=" value
Perform a comparison operation
③
DELIMITER | |Create procedureMypro ()beginDeclareIinteger;SetI=1; startTransaction; whileI<= - DobeginEnd;End while;Commit;End; | |delimiter;
MySQL in while loop and variable declaration and Dilimiter