Week 11 gave us a quick introduction to PL/SQL.

The primary tools of PL SQL are:

  • Anonymous Blocks
  • Named Blocks
  • Subprograms
  • Triggers

Of these subprograms and triggers would be the most commonly used.

The structure of PL/SQL:

DECLARE
/*Declarative section is where variables and other objects such as cursors, types, exceptions, etc. are declared. Local
procedures and functions can also be declared and will be available for this block only. This section is optional */
BEGIN
/* Executable section can consist of both SQL statement and procedural statements. This section is where the work the
block has to perform is done. This section is mandatory */
EXCEPTION
/* Exception handling section is where errors are handled. The code in this section gets executed only when an error
is encountered. This section is optional. */
END;
/

A couple of examples of PL/SQL blocks:

For some basics on PL SQL such as syntax and constructs visit: http://plsql-tutorial.com/index.htm