Oracle added a procedural programming language known as PL/SQL (Procedural Language/SQL) to the database. PL/SQL is built on top of SQL and enables you to write programs that contain SQL statements. PL/SQL is a third-generation language and contains the standard programming constructs you would expect from such a language, such as:
Block structure
Variables and types
Conditional logic
Loops
Cursors, which hold the results returned by a query
Procedures
Functions
Packages, which may be used to group procedures and functions together in one unit
You typically use PL/SQL to add business logic to the database. This centralized code may be called by any program that can access the database, including SQL*Plus, a C program, or a Java program.
Note | For full details on how to access a database through Java, see my book Oracle9i JDBC Programming (Oracle Press, 2002). |
In this chapter, you ll learn about PL/SQL programming. You ll also learn how to create triggers, which are blocks of code that are run when a certain event occurs in the database. Let s plunge in and examine block structure.