stored procedure is a collection of SQL statements with an given name that's stored in the database in compiled format so that it can be used by more
programs again and again.Stored procedures improve performance by reducing network traffic and CPU load.It is created to performing a large operation like
more then one query execute simulteneously.Stored procedures can return result sets.You can use IF,WHILE,LOOP,ITERATION, CASE statements in store procedure

A user-defined function is a set of SQL statements you can call or set a function by name.user-defined function are similar to procedures,but a
function returns a value to the operation in which it is called.
user defined function use the folowing:
statement
The SET clause in UPDATE statement
WHERE clause
The VALUES clause in INSERT statement
START WITH, ORDER BY, and GROUP BY clauses