What is Difference between StoredProcedure and function?

Answers were Sorted based on User's Feedback



What is Difference between StoredProcedure and function?..

Answer / shankar

FUNCTION always return a value where as PROCEDURE may or
may not return value.

Is This Answer Correct ?    3 Yes 1 No

What is Difference between StoredProcedure and function?..

Answer / 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

What is Difference between StoredProcedure and function?..

Answer / prabhu karanam

We can use a function in the select query, but Procedure we
can't use in select query. But the function created with out
parameter, we can't use in select statement. Only in
parameter, we can use.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

Can you create a table with Primary Key not as the clustered index.

2 Answers   CGI,


What is a memo field?

0 Answers  


What are all the difference between Like and Contains ?

2 Answers   LG Soft,


What is pl sql package?

0 Answers  


what is “go” in t-sql? : Transact sql

0 Answers  






what are pl/sql collections?

4 Answers   JPMorgan Chase, Oracle,


How do I add a primary key to a table?

0 Answers  


table name :Tab fields name 1.trx_no (pk) 2.trx_date 3.account code (7 char) 4.account type (1 char) 5.amt Tab contains account code day wise debit and credit transaction , account type fiels can have 2 value D for debit and c for Credit . write a query to display the account code wise total debit and credit bal for the month of april 2004. write a query to display account code wise new amt credit for the april 2004

2 Answers   Maruti Suzuki,


What is ON DELETE CASCADE?

3 Answers  


what is a control file ? : Sql dba

0 Answers  


What does the sign mean in sql?

0 Answers  


what is difference between delete and truncate commands? : Sql dba

0 Answers  


Categories