In MySQL database context, what is the difference among these 3 terms:
Also the build-in functions like those date time functions (e.g. WEEKDAY()
etc) are considered as what?
The function must return a value but in Stored Procedure it is optional. Even a procedure can return zero or n values. Functions can have only input parameters for it whereas Procedures can have input or output parameters. Functions can be called from Procedure whereas Procedures cannot be called from a Function.
A procedure is a routine that can accept arguments but does not return any values. A function is a routine that can accept arguments and returns one or more values. User-defined routine (UDR) is a generic term that includes both user-defined procedures and user-defined functions.
A function returns a value and control to calling function or code. A procedure returns the control but not any value to calling function or code. A procedure has support for try-catch blocks. A select statement can have a function call.
A view represents a virtual table. You can join multiple tables in a view and use the view to present the data as if the data were coming from a single table. A stored procedure uses parameters to do a function... whether it is updating and inserting data, or returning single values or data sets.
Google is your friend. The first match for "mysql routine function procedure" is this: http://dev.mysql.com/doc/refman/5.0/en/stored-routines-syntax.html
A quick summary:
A stored routine is either a procedure or a function.
A procedure is invoked using a CALL statement and can only pass back values using output variables.
A function can be called from inside a statement just like any other function and can return a scalar value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With