What Is PL/SQL?

PL/SQL is a procedural programming language that's built into Oracle XE. With PL/SQL, you can build programs to process information by combining PL/SQL procedural statements that control program flow with SQL statements that access an Oracle database. For example, the following is a very simple PL/SQL program that updates a part's UNITPRICE, given the part's ID number. (This listing is not an exercise—it is just an example to study.)

CREATE OR REPLACE PROCEDURE updatePartPrice ( partId IN INTEGER, newPrice IN NUMBER ) IS invalidPart EXCEPTION; BEGIN -- HERE'S AN UPDATE STATEMENT TO UPDATE A DATABASE RECORD UPDATE parts SET unitprice = newPrice WHERE id= partId; -- HERE'S AN ERROR-CHECKING STATEMENT IF SQL%NOTFOUND THEN RAISE invalidPart; ...

Get Hands-On Oracle Database 10g Express Edition for Windows now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.