MySQL5 is an example of creating a stored procedure
- 2020-05-07 20:32:54
- OfStack
Login with mysql client
2 select database
mysql > use test
Query which stored procedures the current database has
mysql > show procedure status where Db='test'
Create a simple stored procedure
mysql > create procedure hi() select 'hello';
Once the stored procedure is created, how do you call it
mysql > call hi();
Display the results mysql > call hi();
+-------+
| hello |
+-------+
| hello |
+-------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
6 1 simple storage procedure was successful, this is only a demonstration, the stored procedure can be 1 time to execute multiple sql statements, so php only connect to the database 1 time to query multiple statements; However, to return multiple result sets, you must query with the mysqli extension, or you will get an error can't return a result set in the given context
So to use these new features, it's best to get used to mysqli's php extension library.
2 select database
mysql > use test
Query which stored procedures the current database has
mysql > show procedure status where Db='test'
Create a simple stored procedure
mysql > create procedure hi() select 'hello';
Once the stored procedure is created, how do you call it
mysql > call hi();
Display the results mysql > call hi();
+-------+
| hello |
+-------+
| hello |
+-------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
6 1 simple storage procedure was successful, this is only a demonstration, the stored procedure can be 1 time to execute multiple sql statements, so php only connect to the database 1 time to query multiple statements; However, to return multiple result sets, you must query with the mysqli extension, or you will get an error can't return a result set in the given context
So to use these new features, it's best to get used to mysqli's php extension library.