MySQL stored procedures

Source: Internet
Author: User

A stored procedure (Stored Procedure) is a set of SQL statements that are compiled to perform a particular function, stored in a database, and invoked by the user by specifying the name of the stored procedure and given the parameter (if the stored procedure has parameters).

A stored procedure is a programmable function that is created and saved in the database. It can consist of SQL statements and some special control structures. Stored procedures are useful when you want to perform the same functions on different applications or platforms, or encapsulate specific functionality. Stored procedures in a database can be seen as simulations of object-oriented methods in programming. It allows control over how data is accessed.

1.MySQL creating a Stored procedure:

DELIMITER//

CREATE PROCEDURE procedure_name ([process parameters [,...]])

    BEGIN

Process Body

    END

//

DELIMITER ;

  

 1  DELIMITER // 2  create  procedure  pro_01 (out C Span style= "color: #0000ff;" >int  )  3  begin  4  select  @c :  (* ) from   User_tab;  5  6  // 7  DELIMITER; 
CREATE PROCEDURE

1 #执行过程 2 Call pro_01 (@c);
#执行过程

1 SELECT @c;
SELECT @c;

MySQL stored procedures

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.