GeekInterview.com
Series: Subject: Topic:
Question: 16 of 17

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

Asked by: Interview Candidate | Asked on: Dec 12th, 2005
Showing Answers 1 - 17 of 17 Answers
G AMar

Answered On : 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.

  
Login to rate this answer.
rahulthebest

Answered On : Dec 14th, 2005

View all answers by rahulthebest

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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
usha jayapal

Answered On : 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.

  
Login to rate this answer.
sumit01_77

Answered On : Jan 21st, 2006

View all answers by sumit01_77

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.

Yes  3 Users have rated as useful.
  
Login to rate this answer.
sahu

Answered On : Jan 28th, 2006

View all questions by sahu   View all answers by sahu

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.

  
Login to rate this answer.
aruna

Answered On : 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.

  
Login to rate this answer.
Rajeshwaran

Answered On : 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..

  
Login to rate this answer.
jubydipu

Answered On : Aug 2nd, 2006

Function also accept more than one argument

  
Login to rate this answer.
swathiraj

Answered On : Sep 25th, 2006

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

  
Login to rate this answer.
condemnity

Answered On : Sep 28th, 2006

View all answers by condemnity

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.

  
Login to rate this answer.
John Ambadan

Answered On : Nov 27th, 2006

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

  
Login to rate this answer.
tintintin

Answered On : Jun 4th, 2007

A function can also return multiple values using the out parameter

  
Login to rate this answer.
prasad.gandra

Answered On : Jun 15th, 2007

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

  
Login to rate this answer.
Puneet

Answered On : 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.

  
Login to rate this answer.
sampra

Answered On : Mar 10th, 2008

View all answers by sampra

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

  
Login to rate this answer.

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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Prasanjeet Das

Answered On : 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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.