Mysql stored procedure,
Create a stored procedure
1. Create a stored procedure without parameters.
Delimiter // # The default end mark of mysql is a semicolon, and now it is changed to two slashes. Create procedure pro_student () begin delete from students; end // delimiter; # restore the default end flag.
2. Create a stored procedure with parameters.
Delimiter // create procedure pro_student (in sid int) begin select * from students where id = sid; end // delimiter;
3. Create a stored procedure with output parameters.
Delimiter // create procedure pro_student_count (out coun int) begin select count (*) into coun from students; end // delimiter; call pro_student_count (@ count); select @ count; # result: 2
. Call the stored procedure.
# Call method without parameters: call pro_student # call pro_student (1 );
4. delete a stored procedure
Drop procedure pro_student;