GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 33 of 166    Print  
What is the difference between procedure and function and package, which is the fastest

  
Total Answers and Comments: 9 Last Update: June 06, 2008     Asked by: Suyog 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 01, 2006 15:29:30   #1  
nalini        

RE: What is the difference between procedure and funct...

procedure :- perform an action

Function: - Function used to compute a value and return a value


 
Is this answer useful? Yes | No
May 02, 2006 02:27:56   #2  
Mahesh        

RE: What is the difference between procedure and funct...

1) stored procedures are designed to return its output to the application.
A UDF (User Defines Functions) returns table variables while a SPROC can't return a table variable although it can create a

table.

2) UDFs can't change the server environment or your operating system environment
while a SPROC can.

3) when T-SQL encounters an error the function stops
while T-SQL will ignore an error in a SPROC and proceed to the next statement in your code
(provided you've included error handling support).

4) a SPROC can be used in an XML FOR clause
a UDF cannot be.

5) If you have an operation such as a query with a FROM clause that requires a rowset be drawn from a table or set of

tables then a function will be your appropriate choice.
However when you want to use that same rowset in your application the better choice would be a stored procedure.


 
Is this answer useful? Yes | No
May 29, 2006 03:11:59   #3  
navneet        

RE: What is the difference between procedure and funct...

procedure: It may or may not return a value.

function: It always return a value.

procedure :it can't be used in select query.for example if we have a procedure abc(salary number ) then we can't use it as select abc(salary) from employee.

whereas we can use functions in a query . select sum(salary) from employee


 
Is this answer useful? Yes | No
February 18, 2007 21:04:21   #4  
madhuk17 Member Since: February 2007   Contribution: 15    

RE: What is the difference between procedure and funct...
Package-->It stores and compiles all the functions and procedures declared in SGA(System Global Area).Whenever stored procedures or functions are called from this package it will get them from SGA.So it perfomance is definetly high.


Procedures-->They are subprograms which perform certain action.They cannot be called from select statement.

Functions-->They are subprograms which return a value.They can be used in select statement and also its return value can be assigned to a variable.


 
Is this answer useful? Yes | No
March 08, 2007 23:51:09   #5  
BASAVARAJ KOLUR        

RE: What is the difference between procedure and funct...
main diffences between procedure and function as follows

procedure function
1>procedure is used for performing 1> its used for computing value
action and returning value

2> procedure may or maynot return 2> function must and should
value return value

3>it cant be used inside sql statement 3>it can be called inside sql
statement
4> its cant be called as part of expression 4>its always called as part of
expression

 
Is this answer useful? Yes | No
April 12, 2007 10:04:43   #6  
sayeed321in Member Since: April 2007   Contribution: 4    

RE: What is the difference between procedure and funct...
Hi guys.......
nobody is concentrating in the second part of the question.....
plz post your comments on the second part of Question......
which is more better for use....function procedure or a package....
Thanx & Regards
Ahmed Sayeed

 
Is this answer useful? Yes | No
June 12, 2007 23:08:36   #7  
madhug56 Member Since: November 2005   Contribution: 13    

RE: What is the difference between procedure and funct...
Second part answer is Package

Packages are faster when compared to procedure and function.This is because you can store related objects together.

 
Is this answer useful? Yes | No
June 28, 2007 23:12:38   #8  
CHINMAY JAIN        

RE: What is the difference between procedure and funct...
Package is faster when you working on specific project and all your functions and procedure are in that package.
because package load into memory and remain in memory till the place available so execution is fast.
for calling realted procedure function and global variable.




but if you have a small and misc work. then you should use single function or procedure
it will take a small memory and load fast


bye

 
Is this answer useful? Yes | No
June 06, 2008 06:01:00   #9  
gokulkm Member Since: June 2008   Contribution: 1    

RE: What is the difference between procedure and function and package, which is the fastest
no difference
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape