Delimiter//mysql>CREATEPROCEDUREHello() ->SELECT*fromStudent_info;//QueryOK, 0rowsaffected(0.08sec) we can see"/> Delimiter//mysql>CREATEPROCEDUREHello() ->SELECT*fromStudent_info;//QueryOK, 0rowsaffected(0.08sec) we can see">
We can create MySQL stored procedures without "BEGIN" and "END" just like creating stored procedures using them, the only thing is to omit BEGIN and END. In the example below, we create a stored procedure without "BEGIN" and "END" to get all the rows in the table -
mysql> Delimiter // mysql> CREATE PROCEDURE Hello() -> SELECT * from Student_info; // Query OK, 0 rows affected (0.08 sec)
We can see that MySQL creates Stored procedures do not have BEGIN and END. Now call it via CALL statement -
mysql> Delimiter ; mysql> CALL Hello(); +-----+---------+------------+------------+ | id | Name | Address | Subject | +-----+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla | Computers | +------+---------+------------+------------+ 3 rows in set (0.18 sec) Query OK, 0 rows affected (0.28 sec)
The above is the detailed content of How can we create a MySQL stored procedure without "BEGIN" and "END"?. For more information, please follow other related articles on the PHP Chinese website!