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

Source: Internet
Author: User

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

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.