Reputation: 9952
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?
Upvotes: 81
Views: 58531
Reputation: 475
PROCEDURES VS FUNCTIONS
Upvotes: 5
Reputation: 1320
Here I have tried to summarize the differences between functions and procedures:
SELECT func_name FROM DUAL
while procedures cannot.Upvotes: 57
Reputation: 21
Function must return a value but in Stored Procedure it is optional( Procedure can return zero or n values). Functions can have only input parameters for it whereas Procedures can have input/output parameters . Functions can be called from Procedure whereas Procedures cannot be called from Function.
Upvotes: 2
Reputation: 1099
Difference between MySQL function and mysql procedure
MYSQL Function
It must return value.
IN
,OUT
andINOUT
cannot be used in function.But return datatype must be declare when create a function. function can be called from a SQL statement. Function return one values.
MYSQL Procedure
Return Values is not mandatory but may be uses the OUT parameter to procedure returns. Can use the
IN
|OUT
|INOUT
parameters. Procedure cannot be called from the SQL Statement. procedure return multiple values by usingOUT
orINOUT
parameters.
Upvotes: 31
Reputation: 24360
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.
Upvotes: 90