Mysql Stored Procedure

Source: Internet
Author: User

Note: The name of a stored procedure in mysql must be enclosed by brackets, even if there is no parameter transfer for the stored procedure. 1. Basic Syntax:

Create procedure sp_name () begin ...... end modify the command Terminator delimiter $

 

Example:
Create procedurecreate procedure myproce () beginINSERT INTO main (num) VALUES (15); end; call the stored procedure: call myproce (); view all the stored procedures in the database: show procedure status; view the stored procedure creation Code show create procedure proc_name; Delete the Stored procedure drop procedure proc_name

 

2. Basic Syntax:
Create function hello () RETURNS ...... RETURN

 

Example:
Create functionCREATE FUNCTION hello (s CHAR (20) returns char (50) return concat ('hello, ', s ,'! '); Call functionselect hello ('World'); view the code for creating the stored procedure function. show create function func_name; Delete drop function func_name;

 


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.