Mysql stored procedures and functions

Source: Internet
Author: User
Tags mysql tutorial

Mysql stored procedures and functions are a collection of SQL statements edited and stored in the database. Calling stored procedures and functions can simplify the work of application developers, reduces data transmission in databases and applications to improve the processing capability of mysql databases.

1. What are stored procedures and functions?

Mysql tutorial stored procedures and functionsIt is a collection of SQL statements that have been edited and stored in the database tutorial. Calling stored procedures and functions can simplify the work of application developers and reduce data transmission in databases and applications, this improves the processing capability of the mysql database.

2. Create and modify stored procedures and functions related to stored procedures.

CreateStored Procedures and creation Functions

Create procedure sp_name ()

Create function sp_name ()

Instance that calls the Stored Procedure

Call sp_name ();

You can include dll statements in the mysql stored procedure.Stored ProcedureRun commit, rollback, and so on, but note that the stored procedure cannot contain the load data infile statement. Let's look at an instance that creates a stored procedure.

Mysql> delimiter $;

Mysql>Create procedureSp_bKjia.c0m (in url int, in sitename int, out infodesc int)

-> Reads SQL data

-> Begin

-> Select * from su where url = sitename and domain = 'www. bKjia. c0m'

-> Select foun_rows () into p_asd;

-> End $;

-> Delimiter;

Note: The above is a simple Stored Procedure instance used to query the data of domain = 'www. bKjia. c0m' and return it.

Okay. The source www. bKjia. c0m is reprinted in the original tutorial on this site.

 

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.