Create PROCEDURE Mytestprocname (in score int, out result varchar (100))
BEGIN
IF Score>60 Then
Set result= ' yes ';
ELSE
Set result= ' no ';
END if;
END
Call
Call Mytestprocname (@result);
Select @result//In order to see the results of the reference
A little bit of grammar that comes with a turn
I. Creating a stored Procedure
1. Basic syntax:
CREATE PROCEDURE Sp_name ()
Begin
.........
End
2. Parameter passing
Two. Calling a stored procedure
1. Basic syntax: Call Sp_name ()
Note: The stored procedure name must be appended with parentheses, even if the stored procedure has no parameters passed
Three. Delete a stored procedure
1. Basic syntax:
drop procedure sp_name//
2. Precautions
(1) cannot delete another stored procedure in one stored procedure, only another stored procedure can be called
Four. blocks, conditions, loops
1. Block definition, commonly used
Begin
......
End
You can also alias chunks, such as:
Lable:begin
...........
End lable;
You can use leave lable, jump out of chunks, execute code after chunk
2. Conditional statements
If condition Then
Statement
Else
Statement
End If;
3. Looping statements
1.for Cycle
2.while Cycle
[Label:] While Espression do
Statements
END while [Label];
3.loop Cycle
[Label:] LOOP
Statements
END LOOP [Label];
4.repeat until cycle
[Label:] REPEAT
Statements
UNTIL espression
END REPEAT [Label];
Five. Other common commands
1.show Procedure Status
Displays basic information about all stored procedures in the database, including the owning database, stored procedure name, creation time, etc.
2.show CREATE PROCEDURE Sp_name
Show details of a MySQL stored procedure
MySQL stored procedures out of the parameters, SQL Server is very familiar with the thing to MySQL, tinkering with the big half day. Keep a record of your reminders. Don't look