What is Difference between StoredProcedure and function?

Answer Posted / ganesh sial

1. Function is mainly used in the case where it must
return a value. Where as a procedure may or may not return
a value or may return more than one value using the OUT
parameter.
Â
2. Function can be called from SQL statements where as
procedure can not be called from the sql statements

3. Functions are normally used for computations where as
procedures are normally used for executing business logic.

4. You can have DML (insert,update, delete) statements in a
function. But, you cannot call such a function in a SQL
query.

5. Function returns 1 value only. Procedure can return
multiple values (max 1024).

6.Stored Procedure: supports deferred name resolution.
Example while writing a stored procedure that uses table
named tabl1 and tabl2 etc..but actually not exists in
database is allowed only in during creation but runtime
throws error Function wont support deferred name
resolution.

7.Stored procedure returns always integer value by default
zero. where as function return type could be scalar or
table or table values

8. Stored procedure is precompiled execution plan where as
functions are not.
Â
9.A procedure may modify an object where a function can
only return a value The RETURN statement immediately
completes the execution of a subprogram and returns control
to the caller.
2. Function -
1) Have to return a single value to the calling program
2) Can call functions in sql statements
3) Cannot return images
.


Procedures -
1) Do not return any value except assigning values to OUT
variables
2) Cannot call procedures in sql statements
3) Can return images

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does := mean in pl sql?

654


What are procedures used for?

609


What is the plv (pl/vision) package offers?

722


Can dml statements be used in pl/sql?

674


hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews

1613






Is big data nosql?

605


Why are cursors used?

680


What is blind sql injection?

663


What type of join is sql join?

621


What is pl sql architecture?

588


What does select top 1 do in sql?

625


what is the difference between truncate and delete statement? : Transact sql

651


What is the process of copying data from table a to table b?

699


Enlist the characteristics of pl/sql?

1353


In pl/sql, what is bulk binding, and when/how would it help performance?

629