Use of stored procedure in parameters IN parameters are only used to pass information to the procedure and have default values. -- Usage of in parameters in stored procedures DELIMITER ;; CREATE PROCEDURE name_in(IN `time` VARCHAR(50)) BEGIN SELECT NOW() ,`time`; END ;; CALL name_in('now time'); -- in is a formal parameter. You can define the data type and give the actual parameter DELIMITER when calling the stored procedure;; CREATE PROCEDURE name_in_2(IN `time` VARCHAR(50)) -- Use BEGIN for set assignment SELECT NOW() ,`time`; END ;; SET @wo='now time'; CALL name_in_2(@wo); DELIMITER ;; CREATE PROCEDURE name_in_4(IN `time` VARCHAR(50)) -- DECLARE creates a variable using BEGIN DECLARE `time` DEFAULT 'wo'; -- DECLARE creates a variable that is only valid in the begin-end statement block SELECT NOW() ,`time`;-- END ;; -- You can use DECLARE in a stored procedure -- Create (DECLARE) and assign (SET) values set @variable name = value -- In summary, DECLARE is only valid in the begin-end statement block. Adding @ to set means that the session variable is valid for the connected client in the current connection. Use of out parameters OUT parameters are used only to pass information back from a procedure. DELIMITER ;; CREATE PROCEDURE name_out(IN `one` INT , IN two INT ,OUT shu INT) -- Use of out output parameter BEGIN SET shu=`one`+two; -- directly add two input parameters and assign them to the output parameter set. The variable name means assignment -- set assignment is valid in the current stored procedure. For example, you can use select shu; -- set @The value assigned is valid in the currently connected client END ;; CALL name_out(3,3,@shuchu); 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. The above is the introduction to the detailed use of MySql stored procedure parameters introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: A brief discussion on React Component life cycle functions
>>: Implementation of effective user groups and initial user groups in Linux
The first one: Using the CSS position property &l...
Previously, react.forwardRef could not be applied...
Table of contents 1. Front-end routing implementa...
I mainly introduce how to develop a lucky wheel g...
Table of contents 1. Ordinary functions 2. Arrow ...
Table of contents Stabilization Throttling Summar...
HTML comments, we often need to make some HTML co...
Preface Recently, our company has configured mbp,...
1. Stop the database server first service mysqld ...
MySQL CURDATE Function Introduction If used in a ...
There are many versions of the Java language. In ...
In the front-end layout of the form, we often nee...
MySQL Lock Overview Compared with other databases...
When installing packages on an Ubuntu server, you...
After installing the database, if you accidentall...