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)
- Executableblock (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;
- Data types
- Control structures
- Exception handling