In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Mysql stored procedure
1. Create stored procedure syntax (format)
DELIMITER $CREATE PROCEDURE stored procedure name A (IN passes parameter name an INT,IN passes parameter name b VARCHAR (20), OUT returns parameter name c INT) BEGIN content. END $
Parsing:
IN represents the passed parameter, defines the passed parameter name, and is followed by the passed parameter type (INT,VARCHAR,DOUBLE,.) OUT represents the data returned by the stored procedure after execution, defines the parameter name, and followed by the parameter type (INT,VARCHAR,DOUBLE,.) INOUT indicates that it can be passed in or returned, defining the parameter name Followed by the parameter type (INT,VARCHAR,DOUBLE,.)
two。 Specific syntax and logic in stored procedures
a. Define variable syntax:
DECLARE variable name a parameter type (INT,VARCHAR (20), BOOLEAN,.) [DEFAULT NULL]
Note: the initial value can be set by adding DEFAULT NULL; after the parameter type.
b. Variable assignment:
Method 1 (assign variables directly):
The variable defined by SET a = NEW ()
Method 2 (the result of the sql query is directly assigned to the variable):
The variable a FROM `student` WHERE defined by SELECT `student`.age INTO.
Mode 3 (the result of the sql query is directly assigned to multiple variables):
SELECT `student`.name AS defined variable a, `student`.age AS defined variable b INTO defined variable a, defined variable b FROM `student`.
c. Logical judgment:
# IF judgment: IF conditional statement (3 > 5) execute when THEN condition is TRUE; END IF; # IF ELSE judgment: IF condition (a > 0) THEN condition is (a > 0) execute. ELSE IF condition (a)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.