0% found this document useful (0 votes)
195 views5 pages

08a - PL-SQL Fundamentals I - Nested Blocks

Nested blocks allow programs to be organized by enclosing one complete PL/SQL block within another. This is useful for handling exceptions, where an exception in an inner block will not cause the entire program to exit. Rules for nested blocks include identifying boundaries with labels and END, a limit of 200 blocks, and blocks can only begin in the BEGIN or EXCEPTION clauses of the enclosing block.

Uploaded by

aditya chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views5 pages

08a - PL-SQL Fundamentals I - Nested Blocks

Nested blocks allow programs to be organized by enclosing one complete PL/SQL block within another. This is useful for handling exceptions, where an exception in an inner block will not cause the entire program to exit. Rules for nested blocks include identifying boundaries with labels and END, a limit of 200 blocks, and blocks can only begin in the BEGIN or EXCEPTION clauses of the enclosing block.

Uploaded by

aditya chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Nested Blocks

• What are Nested Blocks?


• Why Use Nested Blocks?
• Rules for Nested Blocks
• Global vs. Local Objects
• Global vs. Local Exceptions

Oracle 11g PL/SQL Fundamentals I


What are Nested Blocks?
As the size and complexity of your
programs increase, a more advanced way
of organizing the code becomes essential.
• A Nested Block is a complete PL/SQL
program block enclosed within the BEGIN
section of another block.
BEGIN

Outer BEGIN Inner


Block …
Block
END;

END;

Oracle 11g PL/SQL Fundamentals I


Why Use Nested Blocks?
• Nested Blocks are helpful in enclosing
SELECT or other statements that may
generate an exception.
• If an Exception occurs, it is handled by the
Inner Block.
• Processing may continue in the Outer Block
• If a Nested Block were not used in this
example, the entire program would exit
by passing control to the EXCEPTION
Clause.

Oracle 11g PL/SQL Fundamentals I


Rules for Nested Blocks
• There are specific rules associated to
Nested Blocks:
• The boundaries of inner and outer blocks are
identified using labels and the END
statement.
• A maximum of 200 Nested Blocks may be
created.
• Nested Blocks may NOT begin within the
DECLARE clause of the enclosing block.
• A Nested Block may only begin within the
BEGIN or EXCEPTION clause of the enclosing
block.

Oracle 11g PL/SQL Fundamentals I


See it in Action

Oracle 11g PL/SQL Fundamentals I

You might also like