Answer» - Function: One of the most fundamental concepts in computer programming is function. It's used to compute anything based on a SET of inputs. User-defined or pre-defined functions are also possible. A BLOCK of code in the function program performs certain duties or functions.
- Procedure: A procedure is a set of instructions or commands used in computer programming. It is referred to as a procedure, subroutine, function, or subprogram depending on the programming language. For example, in SQL both function and procedures are distinct concepts.
The following table lists the differences between functions and procedures: | Function | Procedure |
|---|
| A function is a type of equation that is used to calculate anything from a set of inputs. As a result, it got its name from Mathematics. | A procedure is a collection of commands that are executed in a specific order. | | In SQL, a procedure can invoke a function. | A function, on the other HAND, cannot invoke a procedure in SQL. | | We can't use DML (Data manipulation language) commands LIKE Insert, Delete, or UPDATE inside a SQL function. | DML instructions can be used inside the procedure in SQL. | | SQL queries can call functions. | Procedures, however, cannot be accessed via a SQL query. | | When functions are called, they are compiled each time. | Procedures, on the other hand, are only compiled once and can be called as many times as needed without having to be compiled each time. | | A function's return statement returns the control and result value to the calling code. | The procedure's return statement returns control to the calling code, it cannot return the result value. | | Explicit transaction handles are not supported by the function. | Explicit transaction handles are supported by the procedure. | | The SELECT statement can be used to work on functions. | It is not possible to use it in a SELECT statement. |
|