SlideShare a Scribd company logo
PL/SQL Introduction
Q.> What is PL/SQL?
Ans.> PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension for
SQL and the Oracle relational database. PL/SQL is available in Oracle Database (since version 7). PL/SQL
(Procedural Language extensions to SQL) is designed specifically for the seamless processing of SQL commands.
PL/SQL stored and compiled in the database, runs within the Oracle executable and inherits the robustness,
security, and portability of the Oracle Database. PL/SQL is a combination of SQL along with the procedural features
of programming languages.
Features of PL/SQL
 block (modular) structure
 flow-control statements and loops
 variables, constants, and types
 structured data
 customized error handling
 it allows you to store compiled code directly in the database.
 once a given block of code is loaded into memory, any number of users can use the same copy of it
simultaneously (although behavior is as though each user had her own copy), which is useful for the
Oracle WebServer.
 enables you to define triggers, which are subprograms that the database executes automatically in
response to specified events.
 is tightly integrated with SQL.
 offers extensive error checking.
 supports object-oriented programming.
 It supports developing web applications and server pages.
PL/SQL Syntax PL/SQL block consists of three sub-parts:
 DECLARATIONS
 EXECUTABLE COMMANDS
 EXCEPTION HANDLING DECLARATIONS
This section includes the declarations for variables, cursors, sub-programs, and other elements to be used
in the program.
This section starts with DECLARE keyword.
This section is optional.
EXECUTABLE COMMANDS This section includes executable PL/SQL statements of the program. It
should have at least one executable line of code. This section starts with BEGIN keyword and ends with
END; keyword. This section is mandatory.
EXCEPTION HANDLING This section includes exception(s) that handle errors in the program. This
section starts with EXCEPTION keyword and is placed between BEGIN and END;
Basic structure:
DECLARE
<declarations sections>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling>
END;
Using Comments:
 Single line comments:
Single line comments can be written as:
-- Single line Comment
 Multi-line comments:
Multi-line comments can be written as:
/* Multi-line Comment */
Declaring Variables:
Syntax:
Variable_name data_type;
Or
Variable_name data_type:=value;
Or
Variable_name data_type DEFAULT value;
For example:
vSalary number;
or
vSalary number:=1000;
or
vSalary number DEFAULT 1000;
You can also use CONSTANT and NOT NULL as:
Variable_name CONSTANT data_type NOT NULL :=value;
For example:
vMax CONSTANT number NOT NULL:=100;
When you use CONSTANT or NOT NULL then you must initialize the variable.
PL/SQL identifiers are constants, variables, exceptions, procedures, cursors, and reserved words. The
identifiers consist of a letter optionally followed by more letters, numerals, dollar signs, underscores, and
number signs and should not exceed 30 characters. By default, identifiers are not case-sensitive. So you
can use integer or INTEGER to represent a numeric value. You cannot use a reserved keyword as an
identifier.
Printing a message
To print a message use:
dbms_output.put_line(‘message’);
To concatenate use ||
dbms_output.put_line(‘message1’||’message2’);
dbms_output.put_line(‘Employee Id: ’||65489);
To print value of a variable use:
dbms_output.put_line(‘Value: ’||variable_name);
Sample PL/SQL Program:
DECLARE
vMessage varchar2(50):=’Welcome to PL/SQL’;
BEGIN
dbms_output.put_line(vMessage);
END;
/
The END; line signals the end of the PL/SQL block. To run the code from SQL command line, you may
need to type / at the beginning of the first blank line after the last line of the code. When the above code is
executed at SQL prompt, it produces the following result:
Welcome to PL/SQL
PL/SQL procedure successfully completed.
Visit: http://pictorialpoint.blogspot.in
Pl sql

More Related Content

What's hot

Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
Sushil Mishra
 

What's hot (18)

PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
Plsql
PlsqlPlsql
Plsql
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online TrainingOracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Training
 
pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql Procedure
 
Pl sql content
Pl sql contentPl sql content
Pl sql content
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Exception handling in plsql
Exception handling in plsqlException handling in plsql
Exception handling in plsql
 
ORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERS
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 
Introduction to PL/SQL
Introduction to PL/SQLIntroduction to PL/SQL
Introduction to PL/SQL
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
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
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Trigger and cursor program using sql
Trigger and cursor program using sqlTrigger and cursor program using sql
Trigger and cursor program using sql
 
PLSQL
PLSQLPLSQL
PLSQL
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
 

Viewers also liked

Cell phone jammer pdf
Cell phone jammer pdfCell phone jammer pdf
Cell phone jammer pdf
Manu M
 

Viewers also liked (15)

DP & Shakespeare
DP & ShakespeareDP & Shakespeare
DP & Shakespeare
 
Pl sql
Pl sqlPl sql
Pl sql
 
sv Principerna & uppståndelse
sv Principerna & uppståndelsesv Principerna & uppståndelse
sv Principerna & uppståndelse
 
センサテクノロジー Sensor Medal, Sensor Shieldの ご紹介
センサテクノロジー Sensor Medal, Sensor Shieldの ご紹介センサテクノロジー Sensor Medal, Sensor Shieldの ご紹介
センサテクノロジー Sensor Medal, Sensor Shieldの ご紹介
 
Agile fundamentals
Agile fundamentalsAgile fundamentals
Agile fundamentals
 
Why SoftLayer? なぜ、EC/通販統合パッケージリーダーのエルテックスは、SoftLayerを選んだのか?
Why SoftLayer? なぜ、EC/通販統合パッケージリーダーのエルテックスは、SoftLayerを選んだのか?Why SoftLayer? なぜ、EC/通販統合パッケージリーダーのエルテックスは、SoftLayerを選んだのか?
Why SoftLayer? なぜ、EC/通販統合パッケージリーダーのエルテックスは、SoftLayerを選んだのか?
 
HTML5プロフェッショナル認定試験対策講座
HTML5プロフェッショナル認定試験対策講座HTML5プロフェッショナル認定試験対策講座
HTML5プロフェッショナル認定試験対策講座
 
Haar like feature
Haar like featureHaar like feature
Haar like feature
 
Monacaソリューションセミナー20160621
Monacaソリューションセミナー20160621Monacaソリューションセミナー20160621
Monacaソリューションセミナー20160621
 
IoT×Emotion
IoT×EmotionIoT×Emotion
IoT×Emotion
 
20151015 iotlt
20151015 iotlt20151015 iotlt
20151015 iotlt
 
SEJ 2016 in Osaka KAITとの共同出展ご案内
SEJ 2016 in Osaka KAITとの共同出展ご案内SEJ 2016 in Osaka KAITとの共同出展ご案内
SEJ 2016 in Osaka KAITとの共同出展ご案内
 
Cell phone jammer pdf
Cell phone jammer pdfCell phone jammer pdf
Cell phone jammer pdf
 
GSM Security
GSM SecurityGSM Security
GSM Security
 
Phonology areeya039
Phonology areeya039Phonology areeya039
Phonology areeya039
 

Similar to Pl sql

PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in databasePL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
ironman82715
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
Ashwin Kumar
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPT
SujayaBiju
 
Advanced_SQL_ISASasASasaASnjection (1).ppt
Advanced_SQL_ISASasASasaASnjection (1).pptAdvanced_SQL_ISASasASasaASnjection (1).ppt
Advanced_SQL_ISASasASasaASnjection (1).ppt
ssuserde23af
 

Similar to Pl sql (20)

PL SQL.pptx in computer language in database
PL SQL.pptx in computer language in databasePL SQL.pptx in computer language in database
PL SQL.pptx in computer language in database
 
pl_sql.ppt
pl_sql.pptpl_sql.ppt
pl_sql.ppt
 
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
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
Pl sql chapter 1
Pl sql chapter 1Pl sql chapter 1
Pl sql chapter 1
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
PLSQL.pptx
PLSQL.pptxPLSQL.pptx
PLSQL.pptx
 
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 TriggerB.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
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
embedded-static-&dynamic
embedded-static-&dynamicembedded-static-&dynamic
embedded-static-&dynamic
 
Introduction to PLSQL.PPT
Introduction to PLSQL.PPTIntroduction to PLSQL.PPT
Introduction to PLSQL.PPT
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Advanced_SQL_ISASasASasaASnjection (1).ppt
Advanced_SQL_ISASasASasaASnjection (1).pptAdvanced_SQL_ISASasASasaASnjection (1).ppt
Advanced_SQL_ISASasASasaASnjection (1).ppt
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Dbms 2011
Dbms 2011Dbms 2011
Dbms 2011
 
Oracle DBA interview_questions
Oracle DBA interview_questionsOracle DBA interview_questions
Oracle DBA interview_questions
 

More from nikhilsh66131 (7)

Pl sql
Pl sqlPl sql
Pl sql
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Html beginners tutorial
Html beginners tutorialHtml beginners tutorial
Html beginners tutorial
 
Bubble and-merge-sort
Bubble and-merge-sortBubble and-merge-sort
Bubble and-merge-sort
 
Java ppt2
Java ppt2Java ppt2
Java ppt2
 
Java ppt2
Java ppt2Java ppt2
Java ppt2
 
Java ppt1
Java ppt1Java ppt1
Java ppt1
 

Recently uploaded

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
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
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
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 

Pl sql

  • 2. Q.> What is PL/SQL? Ans.> PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database (since version 7). PL/SQL (Procedural Language extensions to SQL) is designed specifically for the seamless processing of SQL commands. PL/SQL stored and compiled in the database, runs within the Oracle executable and inherits the robustness, security, and portability of the Oracle Database. PL/SQL is a combination of SQL along with the procedural features of programming languages. Features of PL/SQL  block (modular) structure  flow-control statements and loops  variables, constants, and types  structured data  customized error handling  it allows you to store compiled code directly in the database.  once a given block of code is loaded into memory, any number of users can use the same copy of it simultaneously (although behavior is as though each user had her own copy), which is useful for the Oracle WebServer.  enables you to define triggers, which are subprograms that the database executes automatically in response to specified events.  is tightly integrated with SQL.  offers extensive error checking.  supports object-oriented programming.  It supports developing web applications and server pages.
  • 3. PL/SQL Syntax PL/SQL block consists of three sub-parts:  DECLARATIONS  EXECUTABLE COMMANDS  EXCEPTION HANDLING DECLARATIONS This section includes the declarations for variables, cursors, sub-programs, and other elements to be used in the program. This section starts with DECLARE keyword. This section is optional. EXECUTABLE COMMANDS This section includes executable PL/SQL statements of the program. It should have at least one executable line of code. This section starts with BEGIN keyword and ends with END; keyword. This section is mandatory. EXCEPTION HANDLING This section includes exception(s) that handle errors in the program. This section starts with EXCEPTION keyword and is placed between BEGIN and END; Basic structure: DECLARE <declarations sections> BEGIN <executable command(s)> EXCEPTION <exception handling> END; Using Comments:  Single line comments: Single line comments can be written as: -- Single line Comment  Multi-line comments: Multi-line comments can be written as: /* Multi-line Comment */
  • 4. Declaring Variables: Syntax: Variable_name data_type; Or Variable_name data_type:=value; Or Variable_name data_type DEFAULT value; For example: vSalary number; or vSalary number:=1000; or vSalary number DEFAULT 1000; You can also use CONSTANT and NOT NULL as: Variable_name CONSTANT data_type NOT NULL :=value; For example: vMax CONSTANT number NOT NULL:=100; When you use CONSTANT or NOT NULL then you must initialize the variable. PL/SQL identifiers are constants, variables, exceptions, procedures, cursors, and reserved words. The identifiers consist of a letter optionally followed by more letters, numerals, dollar signs, underscores, and number signs and should not exceed 30 characters. By default, identifiers are not case-sensitive. So you can use integer or INTEGER to represent a numeric value. You cannot use a reserved keyword as an identifier.
  • 5. Printing a message To print a message use: dbms_output.put_line(‘message’); To concatenate use || dbms_output.put_line(‘message1’||’message2’); dbms_output.put_line(‘Employee Id: ’||65489); To print value of a variable use: dbms_output.put_line(‘Value: ’||variable_name); Sample PL/SQL Program: DECLARE vMessage varchar2(50):=’Welcome to PL/SQL’; BEGIN dbms_output.put_line(vMessage); END; / The END; line signals the end of the PL/SQL block. To run the code from SQL command line, you may need to type / at the beginning of the first blank line after the last line of the code. When the above code is executed at SQL prompt, it produces the following result: Welcome to PL/SQL PL/SQL procedure successfully completed. Visit: http://pictorialpoint.blogspot.in