What is the difference between stored procedures and stored functions in ORACLE?

Showing Answers 1 - 34 of 34 Answers

G AMar

  • Dec 13th, 2005
 

Both(functions and Procedures) are the Oracle Objects that work explicitly towards database objects like Tables,Views.

The diff. b/t Stored Procedures and Functions

1) The procedures doesn't return values. whereas the function returns  value.

2) The procedures accept more than one argument whereas the functions not.

  Was this answer useful?  Yes

Both functions and storedprocedures are sequence of SQL statements stored in the database for future accessDifference between them is that:1. Procedures are parsed and compiled. They are stored in compiled format in the database where as Functions are compiled and excuted runtime.Note: I don't agree that functions don't accept more than one parameters. Both functions and procedures can be parameterized with multiple parameters.

usha jayapal

  • Jan 6th, 2006
 

if u r using any DML operations then go for functions and not procedures , as procedures dont return value but function does.

  Was this answer useful?  Yes

sumit01_77

  • Jan 21st, 2006
 

Function :

1. Should return atleast one output parameter.Can return more than one parameter using OUT argument.

2. Parsed and compiled at runtime.

3.Cannot affect the state of database.

4.Can be invoked from SQL statement e.g. SELECT.

5. Functions are mainly used to compute values.

Procedure:

1. Doesn't need to return values, but can return value.

2.Stored as a pseudo-code in database i.e. compiled form.

3.Can affect the state of database using commit etc.

4.Cannnot be invoked from SQL statements e.g. SELECT.

5.Procedures are mainly used to process the tasks.

Ans:

A procedure or function is an object stored in the database, and run as a unit to solve a specific problem or perform a set of related tasks. Procedures and functions permit the caller to provide parameters that can be input only, output only, or input and output values. Procedures and functions let you combine the ease and flexibility of SQL with the procedural functionality of a structured programming language.

Procedures and functions are identical except that functions always return a single value to the caller, while procedures do not.

  Was this answer useful?  Yes

aruna

  • Apr 3rd, 2006
 

botj storedprocedures & functions are collection of some sql statements to perform a particular task

but the diff is procedure doesn't return value.but functions return value.

  Was this answer useful?  Yes

Rajeshwaran

  • Jun 3rd, 2006
 

The main diff beween procedure and function is

function can be invoked from an select statement ,update statments

but the procedure cannot;

And a procedure can return more than one values using OUT parameter.but a funtion can return only one value to the calling environments buy the return keyword.....

This is for u r kind information..

  Was this answer useful?  Yes

jubydipu

  • Aug 2nd, 2006
 

Function also accept more than one argument

  Was this answer useful?  Yes

swathiraj

  • Sep 25th, 2006
 

i dont agree that procedures dont hav any return values because they do have out parameters

  Was this answer useful?  Yes

condemnity

  • Sep 28th, 2006
 

Without a doubt, procedures CAN return values. I think the general rule of thumb is if you need more than one value returned from a function, use a procedure instead.

  Was this answer useful?  Yes

John Ambadan

  • Nov 27th, 2006
 

Of course, the procedure can pass values to its calling environment, but it can?t RETURN any value. Only function can RETURN value.

  Was this answer useful?  Yes

tintintin

  • Jun 4th, 2007
 

A function can also return multiple values using the out parameter

  Was this answer useful?  Yes

prasad.gandra

  • Jun 15th, 2007
 

Stored Procedures accepts parameters like ( in, out, inout )

  Was this answer useful?  Yes

Puneet

  • Jul 13th, 2007
 

1. a function always return a value. but an stored procedure may return value or not.
2. you can use output parameter with stored procedure but you can not do it with Function.

  Was this answer useful?  Yes

sampra

  • Mar 10th, 2008
 

store procedure dsnt return any value but we can return many values by stored procedure where as function returns alwas a value functions are of two type 1,aggrigate function 2.scalor function

  Was this answer useful?  Yes

1. A function is used to compute a value. A porucedure is used to execute business logic.
2. A functin must return a value. A procedure may not return a value or may return more than one value using out parameter.
3. A function can be called from DML statements if it obeys purity rules. A procedure can't be called from DML statements.
4. Procedures supports derred name resolution. Functions won't.
5. A function return one value only. A procedure may return upto 1024 values.

Prasanjeet Das

  • May 9th, 2012
 

SP

1-It is a subprogram that perform an action.
2-It does not contain any return clause.
3-Can return none,one or many values.
4-Can contain a return statement.

SF

1-Invoke as a part of expression.
2-Must contain a Return clause.
3-Must return a single value.
4-Must contain at least one return statement.

  Was this answer useful?  Yes

qptopm

  • Jul 22nd, 2016
 

Functions have a scalar return value. Procedures do not have a return value.

A Stored procedure may have arguments that are IN, OUT, or INOUT. Functions may only have IN arguments.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions