I. Creating process syntax
CREATE PROCEDURE procedure name (parameter list)
Begin
--SQL statement ...
End
-- create a stored procedure delimiter $$ Create procedure my_act () begin Select * from goods; End $ $delimiter;
Second, the review process
-- View All Procedures procedure status [ like ' pattern ']; -- View procedure Creation statements Create procedure process name;
Third, Procedure call
-- procedure calls call procedure name ();
Iv. Process Removal
-- Delete procedure Drop procedure process name;
Five, detailed process parameters
Compared to a function, the parameters of the procedure have more than three qualifier modifiers:
1. In-the value is passed, the parameter can be a number or a variable, and the internal modification of the procedure does not affect the external.
2. Out--reference pass, parameter can only be variable. The data in the pre-use variable will be empty. The value generated in the procedure is passed to the external variable at the end of the procedure call.
3. InOut--Reference pass, parameter can only be a variable. External data can be passed to internal use, internal modifications will also be external. The external value is changed only after the call is finished.
How to use: CREATE PROCEDURE procedure name ([in Parameter name parameter type,][out parameter Name argument type,][inout parameter name, parameter type])
--Creating global VariablesSet @ga = 1;Set @gb = 2;Set @gc = 3;--Sample Process Parametersdelimiter $$Create procedurePro_demo (inchXint, Out Yint, InOut Zint)begin --view changes after the data entry process Selectx, y, Z; --Modifying the value of a local variable SetX= -; SetY= $; SetZ= -; --to view the value of a local variable Selectx, y, Z; --View the value of a global variable to see if the modification of the local variable has an effect on the global Select @ga,@gb,@gc; --Modifying the value of a global variable Set @ga = 'a'; Set @gb = 'b'; Set @gc = 'C'; --View the value of the global variable before the call ends to observe the change to the global variable after the procedure call ends Select @ga,@gb,@gc;End$ $delimiter;--Call ProcedureCall Pro_demo (@ga,@gb,@gc);--observe the value of the global variable again after the procedure call endsSelect @ga,@gb,@gc;
The process procedure in MySQL