SlideShare a Scribd company logo
PL/SQL is a block structured language that enables developers to combine the power of SQL with procedural statements
Contents
 What is PL/SQL
 Architecture PL/SQL
 Difference sql/plsql
 Blocks
 Variables
 Hello program
PL/SQL
 PL/SQL is an extension of Structured Query Language (SQL)
that is used in Oracle. Unlike SQL, PL/SQL allows the
programmer to write code in a procedural format.
 Full form of PL/SQL is "Procedural Language extensions to
SQL".
 It combines the data manipulation power of SQL with the
processing power of procedural language to create super
powerful SQL queries.
 PL/SQL means instructing the compiler 'what to do' through
SQL and 'how to do' through its procedural way.
 Similar to other database languages, it gives more control to
the programmers by the use of loops, conditions and object-
oriented concepts.
 Disadvantages of SQL:
 SQL doesn’t provide the programmers with a
technique of condition checking, looping and
branching.
 SQL statements are passed to Oracle engine one at a
time which increases traffic and decreases speed.
 SQL has no facility of error checking during
manipulation of data.
Advantages of Pl/sql
 Block structures
 Procedural language capability
 Better performance
 Error handling
SQL PL/SQL
SQL is a single query that is
used to perform DML and
DDL operations.
PL/SQL is a block of codes
that used to write the entire
program blocks/ procedure/
function, etc.
It is declarative, that defines
what needs to be done,
rather than how things need
to be done.
PL/SQL is procedural that
defines how the things
needs to be done.
Execute as a single
statement.
Execute as a whole block.
Mainly used to manipulate
data.
Mainly used to create an
application.
Cannot contain PL/SQL
code in it.
It is an extension of SQL, so
it can contain SQL inside it.
Architecture of Pl/sql
 The PL/SQL architecture mainly consists of following
three components:
 PL/SQL block
 PL/SQL Engine
 Database Server
Architecture
PL/SQL block:
 This is the component which has the actual PL/SQL code.
 This consists of different sections to divide the code logically (declarative
section for declaring purpose, execution section for processing statements,
exception handling section for handling errors)
 It also contains the SQL instruction that used to interact with the database
server.
 All the PL/SQL units are treated as PL/SQL blocks, and this is the starting stage
of the architecture which serves as the primary input.
 Following are the different type of PL/SQL units.
 Anonymous Block
 Function
 Library
 Procedure
 Package Body
 Package Specification
 Trigger
 Type
 Type Body
 PL/SQL Engine
 PL/SQL engine is the component where the actual
processing of the codes takes place.
 PL/SQL engine separates PL/SQL units and SQL part
in the input The separated PL/SQL units will be
handled by the PL/SQL engine itself.
 The SQL part will be sent to database server where the
actual interaction with database takes place.
 It can be installed in both database server and in the
application server.
 Database Server:
 This is the most important component of Pl/SQL unit
which stores the data.
 The PL/SQL engine uses the SQL from PL/SQL units
to interact with the database server.
 It consists of SQL executor which parses the input SQL
statements and execute the same.
Plsql block
 Blocks contain both PL/SQL as well as SQL
instruction. All these instruction will be executed as a
whole rather than executing a single instruction at a
time.
 PL/SQL blocks have a pre-defined structure in which
the code is to be grouped. Below are different sections
of PL/SQL blocks.
 Declaration section
 Execution section
 Exception-Handling section
Block Structure
PL/SQL is a block structured language that enables developers to combine the power of SQL with procedural statements
 Declare section starts with DECLARE keyword in which
variables, constants, records as cursors can be declared
which stores data temporarily. It basically consists
definition of PL/SQL identifiers. This part of the code is
optional.
 Execution section starts with BEGIN and ends
with END keyword. This is a mandatory section and here
the program logic is written to perform any task like loops
and conditional statements. It supports
all DML commands, DDL commands and SQL*PLUS
built-in functions as well.
 Exception section starts with EXCEPTION keyword.This
section is optional which contains statements that are
executed when a run-time error occurs. Any exceptions
can be handled in this section.
 Types of PL/SQL block
PL/SQL blocks are of mainly two types.
 Anonymous blocks
 Named Blocks
Connecting to database
Simple hello program
snapshot
PL/sql identifiers
 Variables:
Variables in PL/SQL must be declared prior to its use.
They should have a valid name and data type as well.
 Syntax for declaration of variables:
 variable _name datatype [NOT NULL := value ];
Naming rules for PL/SQL variables
 The variable in PL/SQL must follow some naming
rules like other programming languages.
 The variable_name should not exceed 30 characters.
 The name of the variable must begin with ASCII letter.
The PL/SQL is not case sensitive so it could be either
lowercase or uppercase. For example: v_data and
V_DATA refer to the same variables.
 You should make your variable easy to read and
understand, after the first character, it may be any
number, underscore (_) or dollar sign ($).
 NOT NULL is an optional specification on the
variable.
 Declaring and usage of variables in the program
Variable scope
 Global variable
 Local variable
 Example of both local and global variable
Comments
 Commenting code simply instructs the compiler to
ignore that particular code from executing.
 Comment can be used in the program to increase the
readability of the program. In PL/SQL codes can be
commented in two ways.
 Single line comment(---)
 Multiline comment(/*…………………*/)
example
Constants
 A constant is a value used in a PL/SQL block that remains
unchanged throughout the program.
 It can be declared and used instead of actual values.
 Syntax:
constant_name CONSTANT datatype := VALUE;
PL/SQL is a block structured language that enables developers to combine the power of SQL with procedural statements
LOOP
Syntax: LOOP
Sequence of statements;
END LOOP;
BASIC LOOP
Ad

Recommended

PL/SQL
PL/SQL
GunavathyShanmuganat
 
Chapter 1
Chapter 1
pooja_123
 
pl_sql.ppt
pl_sql.ppt
Prabhat106214
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Training
suresh
 
PL/SQL Complete Tutorial. All Topics Covered
PL/SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPT
SujayaBiju
 
Pl sql chapter 1
Pl sql chapter 1
PrabhatKumar591
 
Pl sql-ch1
Pl sql-ch1
Mukesh Tekwani
 
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
Assistant Professor, Shri Shivaji Science College, Amravati
 
Unit 4 rdbms study_material
Unit 4 rdbms study_material
gayaramesh
 
PLSql.pptx
PLSql.pptx
Sreenivas R
 
PL/SQL for Beginners - PL/SQL Tutorial 1
PL/SQL for Beginners - PL/SQL Tutorial 1
Gurpreet singh
 
PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
rdbms.pdf plsql database system notes for students to study
rdbms.pdf plsql database system notes for students to study
rarelyused
 
This is regarding to introduction of PL SQL
This is regarding to introduction of PL SQL
cm44228
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql Prograaming of Database management system
Pl sql Prograaming of Database management system
AjitPatil801582
 
Dbms 2011
Dbms 2011
Atiqa Khan
 
Sql presntation
Sql presntation
BE Smârt
 
L9 l10 server side programming
L9 l10 server side programming
Rushdi Shams
 
Unit 4 plsql
Unit 4 plsql
DrkhanchanaR
 
PLSQL Tutorial
PLSQL Tutorial
Quang Minh Đoàn
 
Ppt on plssql study aboutnsmsmskskwkwkwkwk
Ppt on plssql study aboutnsmsmskskwkwkwkwk
DrStrange634619
 
PL_SQL, Trigger, Cursor, Stored procedure ,function
PL_SQL, Trigger, Cursor, Stored procedure ,function
RajendraKankrale1
 
Chapter8 pl sql
Chapter8 pl sql
Jafar Nesargi
 
DBMS 2011
DBMS 2011
Atiqa khan
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 

More Related Content

Similar to PL/SQL is a block structured language that enables developers to combine the power of SQL with procedural statements (20)

B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
Assistant Professor, Shri Shivaji Science College, Amravati
 
Unit 4 rdbms study_material
Unit 4 rdbms study_material
gayaramesh
 
PLSql.pptx
PLSql.pptx
Sreenivas R
 
PL/SQL for Beginners - PL/SQL Tutorial 1
PL/SQL for Beginners - PL/SQL Tutorial 1
Gurpreet singh
 
PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
rdbms.pdf plsql database system notes for students to study
rdbms.pdf plsql database system notes for students to study
rarelyused
 
This is regarding to introduction of PL SQL
This is regarding to introduction of PL SQL
cm44228
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql
Pl sql
nikhilsh66131
 
Pl sql Prograaming of Database management system
Pl sql Prograaming of Database management system
AjitPatil801582
 
Dbms 2011
Dbms 2011
Atiqa Khan
 
Sql presntation
Sql presntation
BE Smârt
 
L9 l10 server side programming
L9 l10 server side programming
Rushdi Shams
 
Unit 4 plsql
Unit 4 plsql
DrkhanchanaR
 
PLSQL Tutorial
PLSQL Tutorial
Quang Minh Đoàn
 
Ppt on plssql study aboutnsmsmskskwkwkwkwk
Ppt on plssql study aboutnsmsmskskwkwkwkwk
DrStrange634619
 
PL_SQL, Trigger, Cursor, Stored procedure ,function
PL_SQL, Trigger, Cursor, Stored procedure ,function
RajendraKankrale1
 
Chapter8 pl sql
Chapter8 pl sql
Jafar Nesargi
 
DBMS 2011
DBMS 2011
Atiqa khan
 
Unit 4 rdbms study_material
Unit 4 rdbms study_material
gayaramesh
 
PL/SQL for Beginners - PL/SQL Tutorial 1
PL/SQL for Beginners - PL/SQL Tutorial 1
Gurpreet singh
 
PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
rdbms.pdf plsql database system notes for students to study
rdbms.pdf plsql database system notes for students to study
rarelyused
 
This is regarding to introduction of PL SQL
This is regarding to introduction of PL SQL
cm44228
 
Pl sql Prograaming of Database management system
Pl sql Prograaming of Database management system
AjitPatil801582
 
Sql presntation
Sql presntation
BE Smârt
 
L9 l10 server side programming
L9 l10 server side programming
Rushdi Shams
 
Ppt on plssql study aboutnsmsmskskwkwkwkwk
Ppt on plssql study aboutnsmsmskskwkwkwkwk
DrStrange634619
 
PL_SQL, Trigger, Cursor, Stored procedure ,function
PL_SQL, Trigger, Cursor, Stored procedure ,function
RajendraKankrale1
 

Recently uploaded (20)

Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Ad

PL/SQL is a block structured language that enables developers to combine the power of SQL with procedural statements

  • 2. Contents  What is PL/SQL  Architecture PL/SQL  Difference sql/plsql  Blocks  Variables  Hello program
  • 3. PL/SQL  PL/SQL is an extension of Structured Query Language (SQL) that is used in Oracle. Unlike SQL, PL/SQL allows the programmer to write code in a procedural format.  Full form of PL/SQL is "Procedural Language extensions to SQL".  It combines the data manipulation power of SQL with the processing power of procedural language to create super powerful SQL queries.  PL/SQL means instructing the compiler 'what to do' through SQL and 'how to do' through its procedural way.  Similar to other database languages, it gives more control to the programmers by the use of loops, conditions and object- oriented concepts.
  • 4.  Disadvantages of SQL:  SQL doesn’t provide the programmers with a technique of condition checking, looping and branching.  SQL statements are passed to Oracle engine one at a time which increases traffic and decreases speed.  SQL has no facility of error checking during manipulation of data.
  • 5. Advantages of Pl/sql  Block structures  Procedural language capability  Better performance  Error handling
  • 6. SQL PL/SQL SQL is a single query that is used to perform DML and DDL operations. PL/SQL is a block of codes that used to write the entire program blocks/ procedure/ function, etc. It is declarative, that defines what needs to be done, rather than how things need to be done. PL/SQL is procedural that defines how the things needs to be done. Execute as a single statement. Execute as a whole block. Mainly used to manipulate data. Mainly used to create an application. Cannot contain PL/SQL code in it. It is an extension of SQL, so it can contain SQL inside it.
  • 7. Architecture of Pl/sql  The PL/SQL architecture mainly consists of following three components:  PL/SQL block  PL/SQL Engine  Database Server
  • 9. PL/SQL block:  This is the component which has the actual PL/SQL code.  This consists of different sections to divide the code logically (declarative section for declaring purpose, execution section for processing statements, exception handling section for handling errors)  It also contains the SQL instruction that used to interact with the database server.  All the PL/SQL units are treated as PL/SQL blocks, and this is the starting stage of the architecture which serves as the primary input.  Following are the different type of PL/SQL units.  Anonymous Block  Function  Library  Procedure  Package Body  Package Specification  Trigger  Type  Type Body
  • 10.  PL/SQL Engine  PL/SQL engine is the component where the actual processing of the codes takes place.  PL/SQL engine separates PL/SQL units and SQL part in the input The separated PL/SQL units will be handled by the PL/SQL engine itself.  The SQL part will be sent to database server where the actual interaction with database takes place.  It can be installed in both database server and in the application server.
  • 11.  Database Server:  This is the most important component of Pl/SQL unit which stores the data.  The PL/SQL engine uses the SQL from PL/SQL units to interact with the database server.  It consists of SQL executor which parses the input SQL statements and execute the same.
  • 12. Plsql block  Blocks contain both PL/SQL as well as SQL instruction. All these instruction will be executed as a whole rather than executing a single instruction at a time.  PL/SQL blocks have a pre-defined structure in which the code is to be grouped. Below are different sections of PL/SQL blocks.  Declaration section  Execution section  Exception-Handling section
  • 15.  Declare section starts with DECLARE keyword in which variables, constants, records as cursors can be declared which stores data temporarily. It basically consists definition of PL/SQL identifiers. This part of the code is optional.  Execution section starts with BEGIN and ends with END keyword. This is a mandatory section and here the program logic is written to perform any task like loops and conditional statements. It supports all DML commands, DDL commands and SQL*PLUS built-in functions as well.  Exception section starts with EXCEPTION keyword.This section is optional which contains statements that are executed when a run-time error occurs. Any exceptions can be handled in this section.
  • 16.  Types of PL/SQL block PL/SQL blocks are of mainly two types.  Anonymous blocks  Named Blocks
  • 20. PL/sql identifiers  Variables: Variables in PL/SQL must be declared prior to its use. They should have a valid name and data type as well.  Syntax for declaration of variables:  variable _name datatype [NOT NULL := value ];
  • 21. Naming rules for PL/SQL variables  The variable in PL/SQL must follow some naming rules like other programming languages.  The variable_name should not exceed 30 characters.  The name of the variable must begin with ASCII letter. The PL/SQL is not case sensitive so it could be either lowercase or uppercase. For example: v_data and V_DATA refer to the same variables.  You should make your variable easy to read and understand, after the first character, it may be any number, underscore (_) or dollar sign ($).  NOT NULL is an optional specification on the variable.
  • 22.  Declaring and usage of variables in the program
  • 23. Variable scope  Global variable  Local variable  Example of both local and global variable
  • 24. Comments  Commenting code simply instructs the compiler to ignore that particular code from executing.  Comment can be used in the program to increase the readability of the program. In PL/SQL codes can be commented in two ways.  Single line comment(---)  Multiline comment(/*…………………*/)
  • 26. Constants  A constant is a value used in a PL/SQL block that remains unchanged throughout the program.  It can be declared and used instead of actual values.  Syntax: constant_name CONSTANT datatype := VALUE;
  • 28. LOOP Syntax: LOOP Sequence of statements; END LOOP;