In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
MySql how to use stored procedure parameters, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
The use of stored procedure in parameter
The IN parameter, which is used only to pass information to the procedure, is the default value.
-- the use of in parameters in stored procedures DELIMITER;; CREATE PROCEDURE name_in (IN `time` VARCHAR (50)) BEGIN SELECT NOW (), `time`; END;; CALL name_in ('present time');-- in is a formal parameter you can define the data type to call the stored procedure when you can give the argument DELIMITER;; CREATE PROCEDURE name_in_2 (IN `time` VARCHAR (50))-- set assignment using BEGIN SELECT NOW (), `time` END;; SET @ wo=' present time'; CALL name_in_2 (@ wo); DELIMITER;; CREATE PROCEDURE name_in_4 (IN `time` VARCHAR (50))-- variable created by DECLARE using BEGINDECLARE `time`time` wo';-- variable created by DECLARE that is valid only in the begin-end statement block SELECT NOW (), `time`;-- END -- you can use DECLARE in stored procedures-- create (DECLARE) and assign (SET) set @ variable names = value-- Summary DECLARE is only valid in begin-end statement blocks. Set plus @ is a session variable that is valid for connected clients in the current connection.
The use of out parameter
The OUT parameter is only used to return information from the procedure.
The MySQL stored procedure "out" parameter: passes a value from within the stored procedure to the caller.
The initial value of this parameter is null, regardless of whether the caller sets a value for the stored procedure parameter or not.
DELIMITER;; CREATE PROCEDURE name_out (IN `one` INT, IN two INT, OUT shu INT)-- out output parameters use BEGIN SET shu= `one` + two;-- directly two input parameters add up and assign values to the output parameters set variable name means assignment-- set assignment is valid in the current stored procedure, for example, select shu can be used;-- set @ assignment is valid in the current connection customer server. CALL name_out; SELECT @ shuchu AS output parameter;-- when calling a stored procedure, you can define an @ parameter to receive the output parameter, that is, the return value
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.