SlideShare a Scribd company logo
PL/SQL
PL/SQL is Oracle’s procedural language extension to SQL. PL/SQL allows you
to mix SQL statements with procedural statements like IF statement, Looping
structures etc. PL/SQL is the superset of SQL. It uses SQL for data retrieval and
manipulation and uses its own statements for data processing.
PL/SQL program units are generally categorized as follows:
1. Anonymous blocks
2. Stored procedures
Anonymous block:
This is a PL/SQL block that appears within your application. In many
applications PL/SQL blocks can appear where SQL statements can appear. Such
blocks are called as Anonymous blocks.
Stored Procedure:
This is a PL/SQL block that is stored in the database with a name.
Application programs can execute these procedures using the name. Oracle also
allows you to create functions, which are same as procedures but return a value,
and packages, which are a collection of procedures and functions.
PL/SQL Engine
Every PL/SQL block is first executed by PL/SQL engine.
This is the engine that compiles and executes PL/SQL blocks.
PL/SQL engine is available in Oracle Server and certain Oracle
tools such as Oracle Forms and Oracle Reports.
PL/SQL engine executes all procedural statements of a
PL/SQL of the block, but sends SQL command to SQL
statements executor in the Oracle RDBMS. That means PL/SQL
separates SQL commands from PL/SQL commands and executes
PL/SQL commands using Procedural statement executor, which
is a part of PL/SQL.
PL/SQL Engine
Features of PL/SQL
Block structure
PL/SQL is a block-structured language. Each program written in PL/SQL is
written as a block. Blocks can also be nested. Each block is meant for a
particular task.
Variables and constants
PL/SQL allows you to declare variables and constants. Variables are used to
store values temporarily. Variables and constants can be used in SQL and
PL/SQL procedural statements just like an expression.
Features of PL/SQL
Control structures
PL/SQL allows control structures like IF statement, FOR loop, WHILE
loop to be used in the block. Control structures are most important
extension to SQL in PL/SQL. Control structures allow any data process
possible in PL/SQL.
Exception handling
PL/SQL allows errors, called as exceptions, to be detected and handled.
Whenever there is a predefined error PL/SQL raises an exception
automatically. These exceptions can be handled to recover from errors.
Features of PL/SQL
Modularity
PL/SQL allows process to be divided into different modules. Subprograms
called as procedures and functions can be defined and invoked using the
name. These subprograms can also take parameters.
Built-in functions
Most of the SQL functions that we have seen so far in SQL are available
in PL/SQL. These functions can be used to manipulate variables of
PL/SQL.
Features of PL/SQL
Cursors
A cursor is a private SQL area used to execute SQL statements and store
processing information. PL/SQL implicitly uses cursors for all DML
commands and SELECT command that returns only one row. And it also
allows you to define explicit cursor to deal with multiple row queries.
Advantages Of PL/SQL
Support for SQL
PL/SQL allows you to use SQL commands, function and operators. PL/SQL
supports data types of SQL.
PL/SQL also allows SQL statements to be constructed and executed on the
fly. The process of creating SQL statements on the fly is called as Dynamic
SQL. This is different from writing SQL commands at the time of writing the
program, which is called as Static SQL.
Starting from Oracle8i, PL/SQL support native dynamic SQL, which makes
programming Dynamic SQL easier than its predecessor, where we used
DBMS_SQL package.
Advantages Of PL/SQL
Better performance
PL/SQL block is sent as one unit to Oracle server. Without PL/SQL each SQL
command is to be passed to Oracle server, which will increase network traffic
heavily. As a collection of SQL statements is passed as a block to Oracle
server, it improves performance.
Portability
Applications written in PL/SQL are portable to any platform on which Oracle
runs. Once you write a program in PL/SQL, it can be used in any
environment without any change at all.
PL/SQL block
PL/SQL programs are written as blocks. Block allows you to group
logically related statements and declarations.
PL/SQL block is consisting of the following three parts:
Declarative part
Executable part
Exception-handling part
PL/SQL block
Syntax of PL/SQL block:
[DECLARE
declaration of variable
declaration of cursor
declaration of exception ]
BEGIN
executable commands [EXCEPTION exception handlers]
END;
PL/SQL block
Declarative Part
This is the area of the block where variables, cursors etc are declared. All variables
used in the block are to be declared in declarative part.
Executable part
Is the area where we write SQL and PL/SQL commands that are to be executed. This
is the only mandatory part of the entire block.
Exception-handling part
Is the place where we handle exceptions (errors) that are raised in executable part.
Exception handlers handle exceptions. We will discuss more about this in later
chapter.
PL/SQL Data Types
• Scalar -Represents a single value
NUMBER, CHAR, VARCHAR2, DATE, BOOLEAN
• Composite -Is a collection of components
RECORD, TABLE and VARRAY
• Reference -Is a pointer that points to another item
REF CURSOR, REF Object_type
• LOB -Holds a lob locator
BFILE, BLOB, CLOB, and NCLOB
Exception’s
In PL/SQL, errors and warnings are called as exceptions. Whenever
a predefined error occurs in the program, PL/SQL raises an
exception.
For example, if you try to divide a number by zero then PL/SQL
raises an exception called ZERO_DIVIDE and if SELECT can not
find a record then PL/SQL raises exception NO_DATA_FOUND.
PL/SQL has a collection of predefined exceptions. Each exception
has a name. These exceptions are automatically raised by PL/SQL
whenever the corresponding error occurs
cursor
Oracle uses a work area to execute SQL commands and store
processing information. PL/SQL allows you to access this area
through a name using a cursor.
Implicit cursor
Explicit cursor
Cursor
Implicit Cursor:
PL/SQL declares an implicit cursor for every DML command, and
queries that return a single row. The name of the implicit cursor is
SQL. You can directly use this cursor without any declaration.
Explicit Cursor:
PL/SQL‟s implicit cursor can handle only single-row queries. If you
ever need to select more than one row using SELECT in PL/SQL
then you have to use explicit cursor
Stored Procedure
A stored procedure is a PL/SQL block that is stored in the database
with a name. It is invoked using the name. Each procedure is
meant for a specific purpose.
A stored procedure is stored in the database as an object. It is also
called as database procedure as it is stored in the database.
A procedure may take one or more parameters. If a procedure
takes parameters then these parameters are to be supplied at the
time of calling the procedure.
Stored Procedure
Advantages of stored procedures
•Reduced network traffic
•Better Performance
•Easy Maintenance
•Security
Triggers
Database trigger is a PL/SQL block that is executed on an event in the
database. The event is related to a particular data manipulation of a
table such as inserting, deleting or updating a row of a table.
Types of Triggers
•Statement-level trigger
•Row-level trigger
•Before triggers
•After triggers
Triggers
Statement-level Triggers:
A statement trigger is fired only for once for a DML statement
irrespective of the number of rows affected by the statement.
Statement-level triggers are typically used to enforce rules that
are not related to data. For example, it is possible to implement a
rule that says “no body can modify BATCHES table after 9
P.M”.
Statement-level trigger is the default type of trigger.
Triggers
Row-level Trigger:
A row trigger is fired once for each row that is affected by DML
command. For example, if an UPDATE command updates 100 rows
then row-level trigger is fired 100 times whereas a statement-level
trigger is fired only for once.
Row-level trigger are used to check for the validity of the data. They
are typically used to implement rules that cannot be implemented by
integrity constraints.
Triggers
Before Triggers:
While defining a trigger, you can specify whether the trigger is to be fired
before the command (INSERT, DELETE, and UPDATE) is executed or
after the command is executed.
Before triggers are commonly used to check the validity of the data before
the action is performed. For instance, you can use before trigger to prevent
deletion of row if deletion should not be allowed in the given case.
Triggers
AFTER Triggers:
After triggers are fired after the triggering action is completed.
For example, If after trigger is associated with INSERT
command then it is fired after the row is inserted into the table.
Oracle PL/SQL online training | PL/SQL online Training

More Related Content

What's hot

Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Achmad Solichin
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기OnGameServer
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
Muthukumaran Subramanian
 
Tema5 sql - ddl
Tema5   sql - ddlTema5   sql - ddl
Tema5 sql - ddl
Alvaro Loustau
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
baabtra.com - No. 1 supplier of quality freshers
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
Srinimf-Slides
 
06 Using More Package Concepts
06 Using More Package Concepts06 Using More Package Concepts
06 Using More Package Concepts
rehaniltifat
 
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified [❤PDF❤] Oracle 19c Database Administration Oracle Simplified
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified
ZanderHaney
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
A brief introduction to SQLite PPT
A brief introduction to SQLite PPTA brief introduction to SQLite PPT
A brief introduction to SQLite PPT
JavaTpoint
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
BG Java EE Course
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Introduction to Oracle Data Guard Broker
Introduction to Oracle Data Guard BrokerIntroduction to Oracle Data Guard Broker
Introduction to Oracle Data Guard Broker
Zohar Elkayam
 
Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09
Thuan Nguyen
 
Oracle sql analytic functions
Oracle sql analytic functionsOracle sql analytic functions
Oracle sql analytic functionsmamamowebby
 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
Charan Reddy
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
Guy Harrison
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
Guilherme Blanco
 

What's hot (20)

Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Tema5 sql - ddl
Tema5   sql - ddlTema5   sql - ddl
Tema5 sql - ddl
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
06 Using More Package Concepts
06 Using More Package Concepts06 Using More Package Concepts
06 Using More Package Concepts
 
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified [❤PDF❤] Oracle 19c Database Administration Oracle Simplified
[❤PDF❤] Oracle 19c Database Administration Oracle Simplified
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
A brief introduction to SQLite PPT
A brief introduction to SQLite PPTA brief introduction to SQLite PPT
A brief introduction to SQLite PPT
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Sql commands
Sql commandsSql commands
Sql commands
 
Introduction to Oracle Data Guard Broker
Introduction to Oracle Data Guard BrokerIntroduction to Oracle Data Guard Broker
Introduction to Oracle Data Guard Broker
 
Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09
 
Oracle sql analytic functions
Oracle sql analytic functionsOracle sql analytic functions
Oracle sql analytic functions
 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 

Viewers also liked

Tableau online training || Tableau Server
Tableau online training || Tableau ServerTableau online training || Tableau Server
Tableau online training || Tableau Server
United Trainings
 
Tableau online training
Tableau online trainingTableau online training
Tableau online training
suresh
 
Pl sql guide
Pl sql guidePl sql guide
Pl sql guide
Vinay Kumar
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05
Thuan Nguyen
 
Qlikview-online-training | Qlikview Server training | Qlikview Designer
Qlikview-online-training | Qlikview Server training | Qlikview DesignerQlikview-online-training | Qlikview Server training | Qlikview Designer
Qlikview-online-training | Qlikview Server training | Qlikview Designer
suresh
 
Grc 10 training
Grc 10 trainingGrc 10 training
Grc 10 training
suresh
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
Steven Feuerstein
 
SAP SECURITY GRC
SAP SECURITY GRCSAP SECURITY GRC
SAP SECURITY GRC
techgurusuresh
 

Viewers also liked (8)

Tableau online training || Tableau Server
Tableau online training || Tableau ServerTableau online training || Tableau Server
Tableau online training || Tableau Server
 
Tableau online training
Tableau online trainingTableau online training
Tableau online training
 
Pl sql guide
Pl sql guidePl sql guide
Pl sql guide
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05
 
Qlikview-online-training | Qlikview Server training | Qlikview Designer
Qlikview-online-training | Qlikview Server training | Qlikview DesignerQlikview-online-training | Qlikview Server training | Qlikview Designer
Qlikview-online-training | Qlikview Server training | Qlikview Designer
 
Grc 10 training
Grc 10 trainingGrc 10 training
Grc 10 training
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
 
SAP SECURITY GRC
SAP SECURITY GRCSAP SECURITY GRC
SAP SECURITY GRC
 

Similar to Oracle PL/SQL online training | PL/SQL online Training

Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
Vaibhav Kathuria
 
Pl sql-ch1
Pl sql-ch1Pl sql-ch1
Pl sql-ch1
Mukesh Tekwani
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-onlyAshwin Kumar
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPT
SujayaBiju
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
pooja_123
 
PL/SQL
PL/SQLPL/SQL
pl_sql.ppt
pl_sql.pptpl_sql.ppt
pl_sql.ppt
Prabhat106214
 
Pl sql chapter 1
Pl sql chapter 1Pl sql chapter 1
Pl sql chapter 1
PrabhatKumar591
 
Pl sql
Pl sqlPl sql
Pl sql
Pl sqlPl sql
Pl sql
Pl sqlPl sql
PL/SQL Complete Tutorial. All Topics Covered
PL/SQL Complete Tutorial. All Topics CoveredPL/SQL Complete Tutorial. All Topics Covered
PL/SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.pptOracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
DheerajKashnyal
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
srijanani2030
 
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
What does PL_SQL stand for and what is the functioning of PL_SQL.docxWhat does PL_SQL stand for and what is the functioning of PL_SQL.docx
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
shivanikaale214
 
Introduction to PL/SQL
Introduction to PL/SQLIntroduction to PL/SQL
Introduction to PL/SQL
Kailash N
 
Pl sql
Pl sqlPl sql
Pl sql
Mahfuz1061
 
Dbms 2011
Dbms 2011Dbms 2011
Dbms 2011
Atiqa Khan
 

Similar to Oracle PL/SQL online training | PL/SQL online Training (20)

Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Pl sql-ch1
Pl sql-ch1Pl sql-ch1
Pl sql-ch1
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPT
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
PL/SQL
PL/SQLPL/SQL
PL/SQL
 
pl_sql.ppt
pl_sql.pptpl_sql.ppt
pl_sql.ppt
 
Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
 
Pl sql chapter 1
Pl sql chapter 1Pl sql chapter 1
Pl sql chapter 1
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
PL/SQL Complete Tutorial. All Topics Covered
PL/SQL Complete Tutorial. All Topics CoveredPL/SQL Complete Tutorial. All Topics Covered
PL/SQL Complete Tutorial. All Topics Covered
 
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.pptOracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
 
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
What does PL_SQL stand for and what is the functioning of PL_SQL.docxWhat does PL_SQL stand for and what is the functioning of PL_SQL.docx
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
 
Introduction to PL/SQL
Introduction to PL/SQLIntroduction to PL/SQL
Introduction to PL/SQL
 
Pl sql
Pl sqlPl sql
Pl sql
 
Dbms 2011
Dbms 2011Dbms 2011
Dbms 2011
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

Oracle PL/SQL online training | PL/SQL online Training

  • 1. PL/SQL PL/SQL is Oracle’s procedural language extension to SQL. PL/SQL allows you to mix SQL statements with procedural statements like IF statement, Looping structures etc. PL/SQL is the superset of SQL. It uses SQL for data retrieval and manipulation and uses its own statements for data processing. PL/SQL program units are generally categorized as follows: 1. Anonymous blocks 2. Stored procedures
  • 2. Anonymous block: This is a PL/SQL block that appears within your application. In many applications PL/SQL blocks can appear where SQL statements can appear. Such blocks are called as Anonymous blocks. Stored Procedure: This is a PL/SQL block that is stored in the database with a name. Application programs can execute these procedures using the name. Oracle also allows you to create functions, which are same as procedures but return a value, and packages, which are a collection of procedures and functions.
  • 3. PL/SQL Engine Every PL/SQL block is first executed by PL/SQL engine. This is the engine that compiles and executes PL/SQL blocks. PL/SQL engine is available in Oracle Server and certain Oracle tools such as Oracle Forms and Oracle Reports. PL/SQL engine executes all procedural statements of a PL/SQL of the block, but sends SQL command to SQL statements executor in the Oracle RDBMS. That means PL/SQL separates SQL commands from PL/SQL commands and executes PL/SQL commands using Procedural statement executor, which is a part of PL/SQL.
  • 5. Features of PL/SQL Block structure PL/SQL is a block-structured language. Each program written in PL/SQL is written as a block. Blocks can also be nested. Each block is meant for a particular task. Variables and constants PL/SQL allows you to declare variables and constants. Variables are used to store values temporarily. Variables and constants can be used in SQL and PL/SQL procedural statements just like an expression.
  • 6. Features of PL/SQL Control structures PL/SQL allows control structures like IF statement, FOR loop, WHILE loop to be used in the block. Control structures are most important extension to SQL in PL/SQL. Control structures allow any data process possible in PL/SQL. Exception handling PL/SQL allows errors, called as exceptions, to be detected and handled. Whenever there is a predefined error PL/SQL raises an exception automatically. These exceptions can be handled to recover from errors.
  • 7. Features of PL/SQL Modularity PL/SQL allows process to be divided into different modules. Subprograms called as procedures and functions can be defined and invoked using the name. These subprograms can also take parameters. Built-in functions Most of the SQL functions that we have seen so far in SQL are available in PL/SQL. These functions can be used to manipulate variables of PL/SQL.
  • 8. Features of PL/SQL Cursors A cursor is a private SQL area used to execute SQL statements and store processing information. PL/SQL implicitly uses cursors for all DML commands and SELECT command that returns only one row. And it also allows you to define explicit cursor to deal with multiple row queries.
  • 9. Advantages Of PL/SQL Support for SQL PL/SQL allows you to use SQL commands, function and operators. PL/SQL supports data types of SQL. PL/SQL also allows SQL statements to be constructed and executed on the fly. The process of creating SQL statements on the fly is called as Dynamic SQL. This is different from writing SQL commands at the time of writing the program, which is called as Static SQL. Starting from Oracle8i, PL/SQL support native dynamic SQL, which makes programming Dynamic SQL easier than its predecessor, where we used DBMS_SQL package.
  • 10. Advantages Of PL/SQL Better performance PL/SQL block is sent as one unit to Oracle server. Without PL/SQL each SQL command is to be passed to Oracle server, which will increase network traffic heavily. As a collection of SQL statements is passed as a block to Oracle server, it improves performance. Portability Applications written in PL/SQL are portable to any platform on which Oracle runs. Once you write a program in PL/SQL, it can be used in any environment without any change at all.
  • 11. PL/SQL block PL/SQL programs are written as blocks. Block allows you to group logically related statements and declarations. PL/SQL block is consisting of the following three parts: Declarative part Executable part Exception-handling part
  • 12. PL/SQL block Syntax of PL/SQL block: [DECLARE declaration of variable declaration of cursor declaration of exception ] BEGIN executable commands [EXCEPTION exception handlers] END;
  • 13. PL/SQL block Declarative Part This is the area of the block where variables, cursors etc are declared. All variables used in the block are to be declared in declarative part. Executable part Is the area where we write SQL and PL/SQL commands that are to be executed. This is the only mandatory part of the entire block. Exception-handling part Is the place where we handle exceptions (errors) that are raised in executable part. Exception handlers handle exceptions. We will discuss more about this in later chapter.
  • 14. PL/SQL Data Types • Scalar -Represents a single value NUMBER, CHAR, VARCHAR2, DATE, BOOLEAN • Composite -Is a collection of components RECORD, TABLE and VARRAY • Reference -Is a pointer that points to another item REF CURSOR, REF Object_type • LOB -Holds a lob locator BFILE, BLOB, CLOB, and NCLOB
  • 15. Exception’s In PL/SQL, errors and warnings are called as exceptions. Whenever a predefined error occurs in the program, PL/SQL raises an exception. For example, if you try to divide a number by zero then PL/SQL raises an exception called ZERO_DIVIDE and if SELECT can not find a record then PL/SQL raises exception NO_DATA_FOUND. PL/SQL has a collection of predefined exceptions. Each exception has a name. These exceptions are automatically raised by PL/SQL whenever the corresponding error occurs
  • 16. cursor Oracle uses a work area to execute SQL commands and store processing information. PL/SQL allows you to access this area through a name using a cursor. Implicit cursor Explicit cursor
  • 17. Cursor Implicit Cursor: PL/SQL declares an implicit cursor for every DML command, and queries that return a single row. The name of the implicit cursor is SQL. You can directly use this cursor without any declaration. Explicit Cursor: PL/SQL‟s implicit cursor can handle only single-row queries. If you ever need to select more than one row using SELECT in PL/SQL then you have to use explicit cursor
  • 18. Stored Procedure A stored procedure is a PL/SQL block that is stored in the database with a name. It is invoked using the name. Each procedure is meant for a specific purpose. A stored procedure is stored in the database as an object. It is also called as database procedure as it is stored in the database. A procedure may take one or more parameters. If a procedure takes parameters then these parameters are to be supplied at the time of calling the procedure.
  • 19. Stored Procedure Advantages of stored procedures •Reduced network traffic •Better Performance •Easy Maintenance •Security
  • 20. Triggers Database trigger is a PL/SQL block that is executed on an event in the database. The event is related to a particular data manipulation of a table such as inserting, deleting or updating a row of a table. Types of Triggers •Statement-level trigger •Row-level trigger •Before triggers •After triggers
  • 21. Triggers Statement-level Triggers: A statement trigger is fired only for once for a DML statement irrespective of the number of rows affected by the statement. Statement-level triggers are typically used to enforce rules that are not related to data. For example, it is possible to implement a rule that says “no body can modify BATCHES table after 9 P.M”. Statement-level trigger is the default type of trigger.
  • 22. Triggers Row-level Trigger: A row trigger is fired once for each row that is affected by DML command. For example, if an UPDATE command updates 100 rows then row-level trigger is fired 100 times whereas a statement-level trigger is fired only for once. Row-level trigger are used to check for the validity of the data. They are typically used to implement rules that cannot be implemented by integrity constraints.
  • 23. Triggers Before Triggers: While defining a trigger, you can specify whether the trigger is to be fired before the command (INSERT, DELETE, and UPDATE) is executed or after the command is executed. Before triggers are commonly used to check the validity of the data before the action is performed. For instance, you can use before trigger to prevent deletion of row if deletion should not be allowed in the given case.
  • 24. Triggers AFTER Triggers: After triggers are fired after the triggering action is completed. For example, If after trigger is associated with INSERT command then it is fired after the row is inserted into the table.