1. functions MUST return a value, procedures need not be.
2. sp takes input,output parameters, function takes only input parameters.
3. sp can not be called directly into DML statements , but functions can be called directly into DML statements.
4. Procedure can return zero or n values whereas function can return one value which is mandatory.
5. Functions can be called from procedure whereas procedures cannot be called from function.
6. Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
7. We can go for transaction management in procedure whereas we can't go in function.
8. Function can be used inside the queries but Store procedure never used inside the queries For Example
Given below:
select avg(salary) from employee;// allowed here
avg(): is function
Select sp(salary) from employee // Not allowed here
sp(): is stored Procedure
2. sp takes input,output parameters, function takes only input parameters.
3. sp can not be called directly into DML statements , but functions can be called directly into DML statements.
4. Procedure can return zero or n values whereas function can return one value which is mandatory.
5. Functions can be called from procedure whereas procedures cannot be called from function.
6. Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
7. We can go for transaction management in procedure whereas we can't go in function.
8. Function can be used inside the queries but Store procedure never used inside the queries For Example
Given below:
select avg(salary) from employee;// allowed here
avg(): is function
Select sp(salary) from employee // Not allowed here
sp(): is stored Procedure
9. Print function can not be called within the function but it can be called within the stored procedure.
10. A stored procedure can return multiple parameters but a function can return only one value.
No comments:
Post a Comment