Monday, March 9, 2009

Nested Block

AKA: Enclosed Blocks, Child Blocks or Sub-blocks. The higher level is called the Parent Block or the Enclosing Block.

Blocks have a scope. When a variable is in scope, it is visible, otherwise, it needs to be prefixed to be reference. Variables from the parent block are also visible. To reference variables from a package, prefix the item with the package name (pkg.var1)

These are particularly helpful for handling exceptions as control returns to the enclosing block, hence if it occurs in the outside block, the program will just stop.

Procedure/Function/Declare [Is/ Return]
variables
Begin
Declare
Begin
Exception
End;
Exception
End;

No comments:

Post a Comment