Difference between Function and Procedure
Function:
It is one among the fundamental thought in the computer programming. It is used to calculate something from a given input. Hence it got its name from Mathematics. Function can be either user defined or predefined. The function program has a block of code that performs some specific tasks or functions.
Procedure:
In programming a particular set of instructions or commands along known as a procedure. Counting on the programming language it is known as as procedure, subroutine, function or a subprogram.
Difference between Function and Procedure:
| S.NO | Function | Procedure |
|---|---|---|
| 1. | A function is deal with as an expression. | Whereas a procedure isn’t dela with as an expression. |
| 2. | Function is used to calculate something from a given input. Hence it got its name from Mathematics. | While procedure is the set of commands, which are executed in a order. |
| 3. | The function can be called by a procedure. | But a procedure can not be called by a function. |
| 4. | In sql, inside the function we can not use the DML(Data manipulation language) commands such as Insert, Delete, Update. | Here, in sql, inside the procedure we can use DML commands. |
| 5. | Functions can be called through sql queries. | However, the procedure can’t be called through a sql query. |
| 6. | Each time functions are compiled when they are called. | Whereas, procedures are compiled only once and can be called again and again as needed without being compiled each time. |
| 7. | The return statement of a function returns the control and function’s result value to the calling program. | While the return statement of the procedure returns control to the calling program, it can not return the result value. |
| 8. | Function doesn’t support try-catch blocks. | While it supports try-catch blocks. |
| 9. | Function can be operated in the SELECT statement. | While it can’t be operated in the SELECT statement. |
| 10. | Function does not support explicit transaction handles. | While procedure supports explicit transaction handles. |
Recommended Posts:
- Difference between Method and Function in Python
- Difference between function expression vs declaration in JavaScript
- What is the difference between a language construct and a “built-in” function in PHP ?
- Difference between LAN and WAN
- Difference between LED and LCD
- Difference between Blu-ray and DVD
- Difference between H.323 and SIP
- Difference between CLI and GUI
- What is the difference between GUI and CUI?
- Difference between CRT and LCD
- Difference between OOP and POP
- Difference between ++*p, *p++ and *++p
- Difference Between SEO and SEM
- Difference between RPC and RMI
- Difference between C and C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



