Difference between Function and Procedure

Key Difference: In programming languages like C and C++, functions and procedures are used interchangeably to describe subroutines that play a vital role in programming languages. However, in database-oriented programming languages like PL/SQL and Oracle, a function and a procedure slightly differ from each other. The prominent difference between the two is that unlike a procedure, a function must return a value.

Functions and procedures play a vital role in most of the programming languages. They are basically used in modular programming. Modular programming is responsible for dividing a large code into sections of some smaller pieces of code. They are quiet helpful in programming as they reduce the unnecessary duplication of code. This ensures the clarity of a program code. Functions and procedures are helpful in the reusability of the code. In languages like C and C++, a function and a procedure are referred to as one and the same thing. However, in database-oriented programming languages like PL/SQL and Oracle, there is a prominent difference between the two. A function must return a value in PL/SQL and Oracle. However, a procedure in PL/SQL cannot return a value. In Oracle, a procedure can return zero or n values. In Oracle, procedures can have input/output parameters for them, whereas functions can have only input parameters.

A function can be described as a set of instructions that performs a specific task. A function is assigned a name. It is important to mention that generally a code fragment is often referred to as a procedure and a procedure that returns a value is often referred to as a function. Thus, both have many similarities. They have similar components like declaration and calling mechanisms. The difference between the two depends upon the context of the programming language.

In Visual Basic, a procedure is declared as –

[AccessSpecifier] Sub ProcedureName ([ParameterList])


End Sub

In Visual Basic, a function is declared as –

[AccessSpecifier] Function FunctionName ([ParameterList]) _

                             As DataType


End Function

(Return value is specified in a Return expression)

Comparison between Function and Procedure:





It must return a value

A function can be called from SQL

It cannot return a value

A procedure cannot be called from SQL


  • It must return one value
  • Functions can have only input parameters
  • Functions can be called from procedure
  • It can return zero or n values
  • Procedures can have input/output parameters for it
  • Procedures cannot be called from function


Called in expressions; this function call has a value in an expression

Called in procedure statements. They do not give a return value


Visual Basic

Functions are named block programs (procedures) that carry out a specific task and also return a result or value. They are marked by the Function and End Function statements.

A generic name for a block of VB statements that have a declarative statement (sub or function) and a matching ending declaration statement.

Image Courtesy: stackexchange.com

Most Searched in Sports Most Searched in Computers and Internets
Most Searched Non-Alcoholic Drinks Top 10 Most Searched Differences
LG Optimus G Pro vs Samsung Galaxy S4
Accident vs Incident
Liposuction vs Abdominoplasty
Subway vs Underpass

Add new comment

Plain text

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.