PL/SQL – Program Structure

PL/SQL is a block-structured language and programs are divided and written in logical blocks of code. The  basic parts of PL/ SQL blocks are

  • Declarative block ( optional)
  • Executable block  (Mandatory )
  • Exception Handling block (optional) 

Declarative block

It is used to define user defined types, variable which can be used in the executable part for further manipulations.

Executable block

All procedural statement are included between BEGIN and END statements. It consists of the executable PL/SQL statements of the program. It should have at least one executable line of code, which may be NULL command.

Exception Handling block

This block starts with keyword EXCEPTION. Errors that occur during execution will handle in this block.

Notes : 

  • A PL/SQL program is a logical block , which contain any number of nested sub blocks.
  • Block can be nested in the executable and exception handling parts of a PL/SQL block, or a sub program.
  • A PL/ SQL in marked with either a DECLARE or BEGIN keywords and ends with the keyword  END.
  • Only BEGIN and END keywords are mandatory.
  • A semicolon (;) has to be placed after the END keyword.
  cursor declerations;
  user_defined exceptions; 
  <executable command(s)>
   Action to perform when error occured

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s