Types of blocks in PL/SQL

0
Types of blocks in PL/SQL:
A PL/SQL program can be written in various types of blocks, they are 

1) Anonymous block:
  • The block having no name.
  • They are declared at the point in an application, where they are to be executed and are passed to PL/SQL engine for execution at runtime.
  • It cannot be called.
  • There are used in D2K form.

SQL>DECLARE
         BEGIN
               NULL;
         EXCEPTION
         WHEN OTHERS THEN
               NULL;
         END;

2) Named Block:

  • The block having name and they have all the features as specified for the anonymous blocks.
  • Named blocks help in associating with the scope and resolution of variables in different blocks.
  • They give the specifications of the named spaces as provided in high level OOPs languages like C++ and JAVA.
  • Named blocks are conveniences for variable management.
 SQL><<FirstBlock>>          DECLARE
          BEGIN
                 NULL;
          EXCEPTION
          WHEN OTHERS THEN
                 NULL;
          END FirstBlock;

  • Named blocks make the PL/SQL blocks more clear and readable.
  • Named blocks increase the clarity of programming when we attempt the nesting process, and control structures.

3) Sup-Programmed blocks:

  • These are named PL/SQL blocks that can take parameters and can be invoked with in the other anonymous or sub-programmed PL/SQL blocks.
  • These blocks are either is declared as procedures or functions.
  • A procedure block is used for performing an action, and a functional block is used for performing calculation.
  • These sub-programs provides modularity and reusability.
 Click here to go to Back page


About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts