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