Oracle:PL/SQL
Main Page >> Oracle and SQL >> Workbook >> PL/SQL
Advanced SQL Features: PL/SQL AND SQL/2
Introduction to PL/SQL
PL/SQL is Oracle's extension to SQL that allows the database application developer to write block structured procedural code to interrogate the database. It allows the programmer to define variables and complex control structures.
PL/SQL can be incorporated into the suite of applications that Oracle provide to support application development, such as SQL*Forms. As PL/SQL is available in the Oracle range of products the programmer does not need to learn different facilities for each Oracle product.
The following sections cover PL/SQL very briefly. An extensive examination of PL/SQL is outside the scope of an introductory course in SQL.
It's main use is the development of routines that can be shared by application developers.
An Introduction to Database Triggers
Database triggers are programs that are executed after a specific event has happened on a target table, such as inserting a row. They are commonly used for:
- Audit purposes
- Security
- Complex Integrity Checks that cannot be handled by constraints
If you refer back to the employee table EMP and salary grade table SALGRADE you can see that there exists a complex relationship, one not based on Foreign Keys. At present it is possible to insert a row in the EMP table whose salary is not covered by the SALGRADE table. To enforce such a check you can create a trigger and store it within the database.