Introduction to PL-SQL

PL-SQL is an extension of SQL that supports the features of Programming Languages. PL/SQL stands for Procedural Language – Structured Query Language.PL/SQL is supported as internal host language in Oracle Products.

Advantages of PL-SQL

  • Acts as a host language for stored procedures and triggers.
  • Provides the ability to add a middle tier
  • business logic to client/server applications.
  • Provides Portability of code from one environment to another
  • Improves performance of multi-query transactions.
  • Provides error handling

The below diagram shows how a PL/SQL is used along with Oracle Server

  • First, there will be a set of PL/SQL statements and these are input to PL/SQL Engine
  • Then the SQL statements are accepted by the SQL Statement processor as input
  • The SQL Statement process the respective SQL statements and gives the desired output

PL/SQL

PL/SQL Engine and Oracle Server

Difference between SQL and PL/SQL:

  • When a SQL statement is issued on the client computer, the request is made to the database on the server, and the result set is sent back to the client.
  • So, a single SQL statement eventually causes two trips on the network and when multiple SELECT statements are issued, the network traffic increase significantly very fast. For example, four SELECT statements cause eight network trips.
  • If these statements are part of the PL/SQL block, they are sent to the server as a single unit. The SQL statements present in this PL/SQL program are executed at the server side and the result set is sent back as a single unit. There is still only one network trip made as is in case of a single SELECT statement.

The following diagram shows the difference between PL/SQL and SQL in Client-Server architecture

PL-SQL

Applications of PL/SQL:

  • Useful to generate automatic triggers when a certain action occurs
  • Useful in creating functions that perform repeated tasks
  • Can also develop web applications using PL/SQL
  • Also used for applications which should be portable

One can work on PL/SQL in Oracle 10g application. To download Oracle 10g express, click here

Leave a Comment

Your email address will not be published. Required fields are marked *