PL/SQL - Environment Setup

Advertisements


PL/SQL is not a stand-alone 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 Oracle RBDMS Server installed in your machine which will take care of executing SQL commands. 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 32bit or 64 bit version of the installation as per your operating system. Usually there are two files, as I have downloaded for 64 bit Windows7. 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 above two files, you will need to unzip them in a single directory database and under that you will find following sub-directories:

Oracle Sub Directries

Step 1

Now, let's launch Oracle Database Installer using setup file. Following is the first screen. You can provide your email ID and uncheck, check box and click Next button:

Oracle Install 1

Step 2

You will have the following screen, just uncheck the check box and click continue button to proceed.

Oracle install error

Step 3

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

Oracle Install 2

Step 4

I assume you are installing Oracle just for learning purpose and you will install it on your PC or Laptop. So select Desktop Class option and click Next button to proceed:

Oracle Install 3

Step 5

Provide a location, where you will install Oracle Server. Just modify Oracle Base and rest of the locations will set automatically. Second, you will have to provide a password, which will be used by system DBA. Once you provide required information, click Next button to proceed:

Oracle Install 4

Step 6

Just click Next button to proceed:

Oracle Install 5

Step 7

Now, click Finish button to proceed, this will start actual server installation.

Oracle Install 6

Step 8

Just wait, until Oracle starts doing required configuration.

Oracle Install 7

Step 9

Here, Oracle installation will copy required configuration files, so kindly just wait and watch:

Oracle Configuration

Step 10

Once everything is done, you will have the following dialogue box. Just click OK button and come out.

Oracle Configuration

Step 11

Once your installation is done, you will have the following final window.

Oracle Install 8

Final Step

If everything has been done successfully, then it's time to verify your installation. At your command prompt, use the following command if you are using Windows:

sqlplus "/ as sysdba" 

If everything is fine, you should have SQL prompt where you will write your PL/SQL commands and scripts:

PL/SQL Command Prompt

Text Editor

Running large programs from command prompt may land you in inadvertently losing some of the work. So a better option is to use 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 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 PL/SQL scripts, then simply copy your PL/SQL code and then right click on the black window having SQL prompt and use paste option to paste complete code at the command prompt. Finally, just press enter to execute the code, if it is not already executed.



Advertisements
Advertisements