PL/SQL - Environment Setup


In this chapter, we will discuss the Environment Setup of PL/SQL. PL/SQL is not a standalone programming language; it is a tool within the Oracle programming environment. SQL* Plus is an interactive tool that allows you to type SQL and PL/SQL statements at the command prompt. These commands are then sent to the database for processing. Once the statements are processed, the results are sent back and displayed on screen.

To run PL/SQL programs, you should have the Oracle RDBMS Server installed in your machine. This will take care of the execution of the SQL commands. The most recent version of Oracle RDBMS is 11g. You can download a trial version of Oracle 11g from the following link −

Download Oracle 11g Express Edition

You will have to download either the 32-bit or the 64-bit version of the installation as per your operating system. Usually there are two files. We have downloaded the 64-bit version. You will also use similar steps on your operating system, does not matter if it is Linux or Solaris.

  • win64_11gR2_database_1of2.zip

  • win64_11gR2_database_2of2.zip

After downloading the above two files, you will need to unzip them in a single directory database and under that you will find the following sub-directories −

Oracle Sub Directries

Step 1

Let us now launch the Oracle Database Installer using the setup file. Following is the first screen. You can provide your email ID and check the checkbox as shown in the following screenshot. Click the Next button.

Oracle Install 1

Step 2

You will be directed to the following screen; uncheck the checkbox and click the Continue button to proceed.

Oracle install error

Step 3

Just select the first option Create and Configure Database using the radio button and click the Next button to proceed.

Oracle Install 2

Step 4

We assume you are installing Oracle for the basic purpose of learning and that you are installing it on your PC or Laptop. Thus, select the Desktop Class option and click the Next button to proceed.

Oracle Install 3

Step 5

Provide a location, where you will install the Oracle Server. Just modify the Oracle Base and the other locations will set automatically. You will also have to provide a password; this will be used by the system DBA. Once you provide the required information, click the Next button to proceed.

Oracle Install 4

Step 6

Again, click the Next button to proceed.

Oracle Install 5

Step 7

Click the Finish button to proceed; this will start the actual server installation.

Oracle Install 6

Step 8

This will take a few moments, until Oracle starts performing the required configuration.

Oracle Install 7

Step 9

Here, Oracle installation will copy the required configuration files. This should take a moment −

Oracle Configuration

Step 10

Once the database files are copied, you will have the following dialogue box. Just click the OK button and come out.

Oracle Configuration

Step 11

Upon installation, you will have the following final window.

Oracle Install 8

Final Step

It is now time to verify your installation. At the command prompt, use the following command if you are using Windows −

sqlplus "/ as sysdba"

You should have the SQL prompt where you will write your PL/SQL commands and scripts −

PL/SQL Command Prompt

Text Editor

Running large programs from the command prompt may land you in inadvertently losing some of the work. It is always recommended to use the command files. To use the command files −

  • Type your code in a text editor, like Notepad, Notepad+, or EditPlus, etc.

  • Save the file with the .sql extension in the home directory.

  • Launch the SQL*Plus command prompt from the directory where you created your PL/SQL file.

  • Type @file_name at the SQL*Plus command prompt to execute your program.

If you are not using a file to execute the PL/SQL scripts, then simply copy your PL/SQL code and right-click on the black window that displays the SQL prompt; use the paste option to paste the complete code at the command prompt. Finally, just press Enter to execute the code, if it is not already executed.

Advertisements