Differences between Mysql stored procedures and functions bitsCN.com
Differences between Mysql stored procedures and functions
A stored procedure is a collection of user-defined SQL statements involving tasks of a specific table or other objects. you can call the stored procedure. a function is usually a database-defined method, it receives parameters and returns some type of values, and does not involve specific user tables.
Stored procedures and functions have the following differences:
1) In general, the functions implemented by stored procedures must be more complex, while the functions implemented by functions are more targeted. Stored procedures are powerful and can be used to perform a series of database operations, including modifying tables. user-defined functions cannot be used to perform a group of operations to modify the global database status.
2) for stored procedures, parameters such as record sets can be returned, while functions can only return values or table objects. A function can return only one variable, while a stored procedure can return multiple variables. Stored Procedure parameters can be IN, OUT, and INOUT, while functions can only have IN classes ~~ The stored procedure declaration does not require a RETURN type, but the RETURN type must be described during the function declaration. the Function body must contain a valid RETURN statement.
3) stored procedures, you can use undefined functions, and do not allow built-in undefined functions in the user-defined function body.
4) the stored procedure is generally executed as an independent part (EXECUTE statement execution), and the function can be called as a part of the query statement (SELECT call ), because a function can return a table object, it can be located behind the FROM keyword in the query statement. Stored procedures are unavailable in SQL statements, but functions can be used.
BitsCN.com