Procedure: In computer programming a specific set of instructions together called a procedure. Depending on the programming language it can be called as subroutine, subprogram or a function.
Function: It is one of the basic concept in programming of computer. As it name says, it performs a function (work). It can be either user defined or system defined. More technically it is a block of code in program which performs specific task.
Difference between Function and Procedure
|It is set of instructions in a program.||It also a set of instructions, but we can say it’s a variant of a procedure.|
|May or may not return a value to the code called by. It just executes commands.||Functions are very similar to procedures except that they also return a value to the calling sub program.|
|Procedure can contain return statement.||Function should contain return statement.|
|Procedure is set of commands executed in order||Function is used to calculate something from given input to it. So its name came from math.|
|Procedure cannot be called from a function.||Function can be called from a procedure.|
|In SQL, inside procedure we can use DML (Insert, Delete, Update) Commands.||In SQL, inside functions we can’t use DML commands.|
|Pascal, Ada, PL/SQL are some programming languages which uses procedure.||C, C++, Java are some programming languages which uses functions.|