PL/SQL Blocks
A PL/SQL block contains one or more PL/SQL statements. Such a block must at least have the two keywords begin and end:
A D V E R T I S E M E N T
begin
sql statements
end;
declare
However, such a block cannot declare any (local) variables. In order to have local variables, the begin...end block must be preceeded with a declare followed by the variable declarations:
declare
variable declarations
begin
sql statements
end;
exceptions
Additinonally, it is possible to have a exception handler as part of the block. The exception keyword is required for this:
declare
variable declarations
begin
sql statements
exception
exception handler
end;
<<name-for-block>>
declare
variable declarations
begin
sql statements
end;
A block can be named. Such a label can then be the target of a goto and exit statement.
<<name-for-block>>
declare
variable declarations
begin
sql statements
end name-for-block;
A block can be (recursively) nested, that is, a block can contain other blocks, which in turn can again contain other blocks asf.
declare
variable declarations
begin
sql statements
declare
variable declarations
begin
sql statements
exception
exception handler
end;
further-sql-statements
exception
exception handler
end;
|