MySQL stored procedures and functions

Source: Internet
Author: User

Stored Procedures and functions:

To create the sample code:

DELIMITER $ $CREATE PROCEDURE proc (in c_id int, in C_name VARCHAR (a), out Count INT) READS SQL databegin    SELECT *    F ROM course    WHERE cou_no = c_id    OR cou_name = c_name;    SELECT found_rows () into count; END $ $DELIMITER

Other:

1. A stored procedure or function can call other procedures or functions.

2. {READS SQL data| Modifies SQL data|no sql| CONTAINS SQL}: These eigenvalues provide intrinsic information about the use of the data by the subroutine, which is currently provided only to the server, and does not constrain the actual use of the data based on these eigenvalue values.

    • READS SQL Data: A statement that represents a subroutine that contains read data, but does not contain a statement that writes data.
    • Modifies SQL data: Represents the statement that the subroutine contains write data.
    • No SQL: Indicates that the subroutine does not contain SQL statements.
    • CONTAINS SQL: Represents a statement that the subroutine does not contain read or write data.

If these features are not explicitly given, the default value used is contains SQL.  

Test code (performed separately):

Call proc (1, ' Information system ', @a); SELECT @a;

To delete a stored procedure or function code:

DROP PROCEDURE proc;

Navicat Creating stored procedures and Function procedures:

1. Click function, new function

2. Select "Process"

3. Start editing stored procedures or functions

4. Click "Save" to fill in the name

MySQL stored procedures and functions

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.