Introduction to PL/SQL Programming

PL/SQL Basics – Introduction to PL/SQL Programming

PL/SQL stands for Procedural Language/Structured Query Language. It is an extension of Structured Query Language (SQL) developed by Oracle Corporation.

PL/SQL is a database programming language which is used to modify and manipulate the database or a complete database application. PL/SQL provides support for developing Web Applications and Server Pages. PL/SQL can be both a server-side and a client-side database programming language.

Introduction to PL/SQL Programming
We shall be teaching Oracle PL/SQL. However, it will form a strong base for you to manage other databases such as Sybase, NoSQL, MongoDB, etc.

PL/SQL is basically used to execute “queries” or “tasks” (in an easy way) to update or delete or modify or add data into the database.

The prerequisite for PL/SQL is SQL. But, don’t worry if you’re not well versed with SQL. Here, I shall also be giving you hints regarding SQL language and soon would be updating a complete tutorial on SQL.

PL/SQL is one of the top most ranked programming languages for handling databases. Many big companies still use this language for their database operations. So, there are many job opportunities with PL/SQL on your Resume.

The major difference between Structures Query Language(SQL) and Procedural Language/Structured Query Language(PL/SQL) is that the former is a single line or a single statement or a single query executer whereas the latter takes multiple queries at one time in the form of a “block”.

PL/SQL Block

A Block contains more than one number of lines of statements to be executed at one point of time.

SQL executes one query at a time. It executes a single insert/update/delete query at a given time whereas PL/SQL can execute more than a single query in the form of a block. It makes use of terms such as loops, cursors, variables, etc to execute queries. We shall learn more about this in the upcoming PL/SQL tutorials.

PL/SQL optionally uses or requires grouping multiple instructions or statement in a single block and sending the entire block for execution in a single call.

A block of PL/SQL program code contains basically three sections as follows:

1. Declaration Section
2. Execution Section
3. Exception Section

These mentioned sections appear order wise in a PL/SQL Block and cannot be interchanged but can be omitted as per the needs.

Declaration Section

This is an optional section. This section starts with the keyword ‘DECLARE’. This section is used to declare variables, constants, records and cursors, which are used to modify/update/delete/manipulate data in the execution section.

Execution Section

This is a compulsory section for the proper execution of a PL/SQL block or a program. This is the section where the logic of the program or the PL/SQL block is to be mentioned. This section starts with the keyword “BEGIN” and ends with  with the keyword “END”. This section makes use of terms such as SQL statements, Loops and Conditional Statements.

Note: PL/SQL has tight integration with SQL

Exception Section

The Exception section of a PL/SQL Block is an optional section. This section starts with the keyword “EXCEPTION”. This section is used to handle any errors that occur during program execution. It helps normal termination of an abnormal program.

This was all about the introduction to PL/SQL programming. Let us know if you have any queries in the comment section below.

Leave a Reply

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