I didn’t undetstood the difference between Stored Functions and Views.
Using Views in SELECT will execute the query and return the result, but Stored Functions do the same thing, don’t they? So what is the difference? When I use Views and when Stored Functions?
I didn’t undetstood the difference between Stored Functions and Views . Using Views in
Share
View:
A view is a virtual
table. It does not physically exist. Rather, it is created by a queryjoiningone or moretables. Viewreturns a table.Stored procedure: A stored procedure is a group of
Transact-SQLstatements compiled into a single execution plan.stored procedures
returns Output parameters,return codes(which are always an integer value),a result set for each
SELECTstatement contained in the stored procedure or any other stored procedures called by the stored procedure,a global cursor that can be referenced outside the stored procedure.key benefits of stored procedure are
Precompiled execution,reduced client/server traffic,efficient reuse of code,programming abstractionandenhanced security controls.Update:
A stored function is a named PL/SQL Block which is similar to a procedure. The major difference between a procedure and a function is, a function must always return a value, but a procedure may or may not return a value.
1) Return Type: The header section defines the return type of the function. The return datatype can be any of the oracle datatype like varchar, number etc.
2) The execution and exception section both should return a value which is of the datatype defined in the header section