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

PDF
PL-SQL, Cursors & Triggers
PPT
Chapter8 pl sql
PDF
Pl sql-ch2
PDF
Pl sql-ch1
PDF
Pl sql-ch3
PPT
Oracle pl/sql control statments
PPTX
Cursors, triggers, procedures
PPT
PL/SQL Introduction and Concepts
PL-SQL, Cursors & Triggers
Chapter8 pl sql
Pl sql-ch2
Pl sql-ch1
Pl sql-ch3
Oracle pl/sql control statments
Cursors, triggers, procedures
PL/SQL Introduction and Concepts

What's hot (17)

PPTX
PL/SQL Fundamentals I
PPT
PDF
Oracle PL/SQL online training | PL/SQL online Training
PPTX
pl/sql Procedure
PPTX
Pl sql content
PPTX
PLSQL Tutorial
PDF
Exception handling in plsql
PPTX
ORACLE PL SQL FOR BEGINNERS
PPT
PLSQL Cursors
PPTX
Oracle: Cursors
PPTX
Introduction to PL/SQL
PPT
Basic cursors in oracle
PDF
PL/SQL Complete Tutorial. All Topics Covered
DOC
Coding standards
RTF
Trigger and cursor program using sql
PPT
DOC
Oracle etl openworld
PL/SQL Fundamentals I
Oracle PL/SQL online training | PL/SQL online Training
pl/sql Procedure
Pl sql content
PLSQL Tutorial
Exception handling in plsql
ORACLE PL SQL FOR BEGINNERS
PLSQL Cursors
Oracle: Cursors
Introduction to PL/SQL
Basic cursors in oracle
PL/SQL Complete Tutorial. All Topics Covered
Coding standards
Trigger and cursor program using sql
Oracle etl openworld
Ad

Viewers also liked (13)

PDF
Bazrgar et al 2011 Environ Emissi Profile
PDF
年間最大1000万円以上!? カタリストスタートアッププログラム
DOCX
chukwuma ahiakwo cv
PDF
HEALTHFUSE - Driving Peak Vendor Performance
PDF
Audio Context+ at WebAudio.tokyo #1
PDF
サービスリニューアルしてわかったRailsのReactとの付き合い方
PPTX
ICTリテラシー教育を埋め込んだ 社会人基礎力プログラムの設計と実践
PDF
Vue.jsコンポーネントのススメ
PDF
ナレッジを共有する文化をつくるために
PDF
ペパボ de MySQL
PDF
What's New in MySQL 5.7 Replication
PDF
20151215 色で色々遊ぼう
Bazrgar et al 2011 Environ Emissi Profile
年間最大1000万円以上!? カタリストスタートアッププログラム
chukwuma ahiakwo cv
HEALTHFUSE - Driving Peak Vendor Performance
Audio Context+ at WebAudio.tokyo #1
サービスリニューアルしてわかったRailsのReactとの付き合い方
ICTリテラシー教育を埋め込んだ 社会人基礎力プログラムの設計と実践
Vue.jsコンポーネントのススメ
ナレッジを共有する文化をつくるために
ペパボ de MySQL
What's New in MySQL 5.7 Replication
20151215 色で色々遊ぼう
Ad

Similar to Pl sql (20)

PDF
PL/SQL for Beginners - PL/SQL Tutorial 1
PDF
chapter 1.pdfbbbbbbbbbbbbbbbbbbbbbbbbbb
PPTX
PL SQL.pptx in computer language in database
PPTX
PL/SQL is a block structured language that enables developers to combine the ...
PPT
pl_sql.ppt
DOCX
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
PDF
rdbms.pdf plsql database system notes for students to study
PDF
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
DOC
3963066 pl-sql-notes-only
PPTX
Pl sql chapter 1
DOC
Chapter 1
PPTX
Relational Database Management System
PPTX
PLSQL.pptx
PPTX
Dynamic and Embedded SQL for db practices.pptx
PDF
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
PPTX
Pl sql Prograaming of Database management system
PPTX
Cordova training : Day 3 - Introduction to Javascript
PPTX
embedded-static-&dynamic
PPT
Introduction to PLSQL.PPT
PL/SQL for Beginners - PL/SQL Tutorial 1
chapter 1.pdfbbbbbbbbbbbbbbbbbbbbbbbbbb
PL SQL.pptx in computer language in database
PL/SQL is a block structured language that enables developers to combine the ...
pl_sql.ppt
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
rdbms.pdf plsql database system notes for students to study
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
3963066 pl-sql-notes-only
Pl sql chapter 1
Chapter 1
Relational Database Management System
PLSQL.pptx
Dynamic and Embedded SQL for db practices.pptx
B.Sc. II (IV Sem) RDBMS & PL/SQL Unit-5 PL/SQL, Cursor and Trigger
Pl sql Prograaming of Database management system
Cordova training : Day 3 - Introduction to Javascript
embedded-static-&dynamic
Introduction to PLSQL.PPT

More from nikhilsh66131 (8)

PDF
PDF
PDF
Introduction to css
PDF
Html beginners tutorial
PPT
Bubble and-merge-sort
PDF
Java ppt2
PDF
Java ppt2
PDF
Java ppt1
Introduction to css
Html beginners tutorial
Bubble and-merge-sort
Java ppt2
Java ppt2
Java ppt1

Recently uploaded (20)

PDF
Trump Administration's workforce development strategy
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Lesson notes of climatology university.
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Classroom Observation Tools for Teachers
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Complications of Minimal Access Surgery at WLH
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Computing-Curriculum for Schools in Ghana
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
Trump Administration's workforce development strategy
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
Lesson notes of climatology university.
Weekly quiz Compilation Jan -July 25.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Classroom Observation Tools for Teachers
VCE English Exam - Section C Student Revision Booklet
GDM (1) (1).pptx small presentation for students
Orientation - ARALprogram of Deped to the Parents.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Complications of Minimal Access Surgery at WLH
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
01-Introduction-to-Information-Management.pdf
Cell Structure & Organelles in detailed.
Computing-Curriculum for Schools in Ghana
STATICS OF THE RIGID BODIES Hibbelers.pdf

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