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 −
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.
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 −
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.
You will be directed to the following screen; uncheck the checkbox and click the Continue button to proceed.
Just select the first option Create and Configure Database using the radio button and click the Next button to proceed.
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.
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.
Again, click the Next button to proceed.
Click the Finish button to proceed; this will start the actual server installation.
This will take a few moments, until Oracle starts performing the required configuration.
Here, Oracle installation will copy the required configuration files. This should take a moment −
Once the database files are copied, you will have the following dialogue box. Just click the OK button and come out.
Upon installation, you will have the following final window.
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 −
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.