Stored Procedures Comparison with functions
1)In Stored procedures ,
RETURN
keyword is used but without any value being passed.
2)Functions return a value (using the
RETURN
keyword), but for stored procedures this is not compulsory.
3)A function is a subprogram written to perform certain computations and return a single value.
4)Functions could be used in
SELECT
statements, provided they don’t do any data manipulation.
procedures cannot be included in
SELECT
statements.
5)A function can have only
IN
parameters, while stored procedures may have OUT
or INOUT
parameters.
6)A stored procedure can return multiple values using the
OUT
parameter or return no value at all.
Stored Procedures Comparison with view
1)View can be used as a table object
A procedure cannot be used as a table object.
2)you cannot accept parameters and do looping inside a view.
you can accept parameters and do looping inside a procedure
Advantage of Stored Procedures
Advantage
There are following advantage of stored procedure:-
- Execution plan retention and reuse
- Query auto-parameterization
- Encapsulation of business rules and policies
- Application modularization
- Sharing of application logic between applications
- Access to database objects that is both secure and uniform
- Consistent, safe data modification
- Network bandwidth conservation
- Support for automatic execution at system start-up
- Enhanced hardware and software capabilities
- Improved security
- Reduced development cost and increased reliability
- Centralized security, administration, and maintenance for common routines
Disadvantage
If you want to switch to using another vendor's database, then you have to rewrite your stored procedures. Stored procedures are easy to misuse. If you place business logic in them, then you are not separating business logic from data logic - a maintenance headache. There are emerging alternatives to them that remove some of the disadvantages - such as LINQ in the Microsoft .NET world
No comments:
Post a Comment