Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Difference between Function and Procedure:

S.NO Function Procedure

Functions always return a value after the The procedure can return a value using
1.
execution of queries. “IN OUT” and “OUT” arguments.

In SQL, those functions having a DML


statement can not be called from SQL A procedure can not be called using SQL
2.
statements. But autonomous transaction queries.
functions can be called from SQL queries.

Each and every time functions are compiled Procedures are compiled only once but
3. they provide output according to the given they can be called many times as needed
input. without being compiled each time.

A procedure is able to return multiple


4. A Function can not return multiple result sets.
result sets.

The function can be called using Stored While procedures cannot be called from
5.
Procedure. function.

A procedure can be used to read and


6. A function used only to read data.
modify data.

The return statement of a function returns the While the return statement of the
7. control and function’s result value to the procedure returns control to the calling
calling program. program, it can not return the result value.

The function does not support try-catch Procedure supports try-catch blocks for
8.
blocks. error handling.

A function can be operated in the SELECT While it can’t be operated in the SELECT
9.
statement. statement.
S.NO Function Procedure

Functions do not permit transaction


10. It allows transaction management.
management.

In functions, we can use only a table variable. In procedures, we can use temporary
11. Temporary tables can not be created in tables or table variables to store temporary
function. data.

You might also like