Database Reference
In-Depth Information
Here is a list of reasons to use stored procedures:
They eliminate the network.
They allow us to more accurately model the real world in database. They provide us with
access to functionality that is not available through the standard database interface: SQL.
Using PL/SQL, you can write stored procedures for the following:
 Data processing
 Data migration
 Entity behavior, including so-called business rules
 Interfaces
 Reports
The general format of a PL/SQL procedure is as follows:
CREATE OR REPLACE PROCEDURE name
[(parameter[, parameter, ...])]
AS
local declarations
BEGIN
executable statements
[EXCEPTION
exception handlers }
END [name];
8.11 Functions
Functions are another type of stored code. They are very similar to procedures.
Function is a PL/SQL block that returns a single value. Because a function returns a
value, it is said to have a datatype and the return value datatype must be declared in the
header of the function. The function does not necessarily have any parameters, but it
must have a RETURN value declared in the header.
Function is made up of:
1. A declarative part
2. An executable part
3. An optional exception handling part
Here are a few more differences between a procedure and a function:  A function MUST
return a value
 A procedure cannot return a value
 Procedures and functions can both return data in OUT and IN OUT parameters
Search WWH ::




Custom Search