MySQL stored procedure starting from 0 (top)

Source: Internet
Author: User

1, first you have to understand that MySQL is also a language, he can also write programs, but also support logical judgment, if,elseif,else,switch,while and so on the judgment

2, MySQL assignment value of a variable operation: set @a = 1; View this variable as select @a;

3, when you create a stored procedure, you need to select the MySQL database before you can operate, such as creating

(1) CREATE PROCEDURE hanshuming ()//Method body: Select Concat (@a, ' world ');

Concat is a link string, set @a= "Hello";

(2) call is called hanshuming ();

4. Simple introduction to the stored procedure small example

MySQL > DELIMITER////First you want to escape and prevent MySQL from taking your statements as SQL statements

MySQL > CREATE PROCEDURE proc1--proc1 Stored procedure name

(In Parameter1 INTEGER)

BEGIN

-DECLARE variable1 CHAR (10); --declare is a named variable

IF Parameter1 =

SET variable1 = ' birds ';

-ELSE

SET variable1 = ' beasts ';

-END IF;

INSERT into table1 VALUES (variable1);

-END

//

MySQL > DELIMITER;

5. View the stored procedures below the current database

(1) Show procedure status where db= ' database name ' G; --g means formatting.

(2) View detailed information for the current stored procedure

Show CREATE PROCEDURE database name. stored Procedure name G;

650) this.width=650; "src=" https://p3.pstatp.com/large/14a2000606af00902671 "alt=" MySQL stored procedure starting from 0 (up) "/>

(3) Delete a stored procedure

drop procedure Sp_name--name of the stored procedure

Drop PROCEDURE--delete all, don't use it easily

6, the definition of the variable is only in the stored procedure inside, beyond the lost, for example, that is, after the end is gone.

650) this.width=650; "src=" https://p9.pstatp.com/large/14a2000606b5dacbd979 "alt=" MySQL stored procedure starting from 0 (up) "/>

7, the operation of InOut

650) this.width=650; "src=" https://p3.pstatp.com/large/149c0007a97e053fb782 "alt=" MySQL stored procedure starting from 0 (up) "/>

When you call this stored procedure, you cannot put the data directly inside the method, you set the value of the variable, and then you put the variable in

If directly put will error 650) this.width=650; "src=" https://p3.pstatp.com/large/149c0007a985cb3ac043 "alt=" MySQL stored procedure starting from 0 (up) "/>

This should be called

650) this.width=650; "src=" https://p3.pstatp.com/large/149c0007a9a78574f476 "alt=" MySQL stored procedure starting from 0 (up) "/>

The above is only a part, the next will be updated to everyone, we can often come to see!


This article is from the "13274080" blog, please be sure to keep this source http://13284080.blog.51cto.com/13274080/1981147

MySQL stored procedure starting from 0 (top)

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.