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)
It is used to define user defined types, variable which can be used in the executable part for further manipulations.
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.
- 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.
BASIC SYNATX :
DECLARE variables; cursor declerations; user_defined exceptions; BEGIN <executable command(s)> EXCEPTION Action to perform when error occured END;