Procedural Language extension of SQL (PL/SQL) combines SQL with procedural programming features such as looping, conditionals, and reusable blocks. PL/SQL engine processes PL/SQL statements. PL/SQL statements can reside on the client on server.
PL/SQL Blocks
PL/SQL blocks are made up of PL/SQL and SQL statements. A block is a functional unit made up of an optional declaration section, an execution section, and an optional exception or error handling section. A block has the following syntax
DECLARE
variable declaration
BEGIN
Program Execution
EXCEPTION
Exception handling
END;
PL/SQL constants, variables, and records
PL/SQL variables have type and scope. The have the following syntax:
name datatype [NOT NULL := value];
not null and value are optional. All statements end with a semicolon (;).
Setting up environment to run PL/SQL
This sections shows how to setup an environment to setup and run PL/SQL. For PL/SQL, you need to download two pieces of software freely available from Oracle.
First, download Oracle Express Edition. It is a lighter version of Oracle, good enough for non-enterprise level work. In addition, it is a much smaller download.
- Download Oracle Express Edition
- Unzip
- Double-click on setup.exe
- Follow instructions. It will ask you for a password. Write this password or memorize it.
When installation is complete, start the software. You will be prompted for a username and password.
Your username is SYS Your password is whatever you typed during installation
Next, download and installsqldeveloper.
- Download sqldeveloper
- Unzip
- Double-click to install