PLSQL Block Structure
DECLARE
--declarations
(variables, constants, user defined types, cursors)
BEGIN
--processing
/execution (SQL Statements, PLSQL statements)
EXCEPTION
--alternative
actions to be performed when exceptions occurs in processing
END;
DECLARE,
EXCEPTION are optional sections.
BEGIN.. END
are mandatory sections.
Types of Blocks
Anonymous
block.- Block without name
Procedure
-Named PLSQL object /subprogram
Function-
Named PLSQL object/subprogram
Typically
use a procedure to perform an action and a function to compute and return a
value.
Subprograms
are stored in database and can be executed many times. Anonymous block is a onetime
execution program and doesn't store in database.