PL / SQL is a procedural extension to non-procedural language SQL, developed by Oracle Corporation and the full name it is the Procedural Language/Structured Query Language.

It 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, the variable which can be used in the executable part for further manipulations.

Executable block

All procedural statement is 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 a NULL command.

Exception Handling block

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

Notes : 

  • A PL/SQL program is a logical block, which contains any number of nested sub-blocks.
  • Block can be nested in the executable and exception handling parts of a PL/SQL block, or a subprogram.
  • 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.
Basic Syntax :
  cursor declarations;
  user_defined exceptions; 
  <executable command(s)>
   Action to perform when error occurred