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 (15)

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

Similar to Pl sql (20)

PDF
PL/SQL for Beginners - PL/SQL Tutorial 1
PDF
rdbms.pdf plsql database system notes for students to study
PPTX
PL SQL.pptx in computer language in database
PPT
pl_sql.ppt
PDF
Dbms 2011
PPTX
Pl sql Prograaming of Database management system
PDF
Procedural Language/Structured Query Language
PPTX
PL/SQL is a block structured language that enables developers to combine the ...
PPTX
PLSQL.pptx
PPTX
PLSql.pptx
PPTX
SQL Programming in database Management System
PPTX
Pl sql chapter 1
PPTX
PL_SQL, Trigger, Cursor, Stored procedure ,function
PPT
Introduction to PLSQL.PPT
DOC
Chapter 1
PDF
Lecture Notes Unit5 chapter 15 PL/SQL Programming
PDF
RDBMS - UNIT 4.pdf,UNIT THREE AND UNIT FIVE
PPT
Cursores.ppt
DOCX
Oracle pl sql
PL/SQL for Beginners - PL/SQL Tutorial 1
rdbms.pdf plsql database system notes for students to study
PL SQL.pptx in computer language in database
pl_sql.ppt
Dbms 2011
Pl sql Prograaming of Database management system
Procedural Language/Structured Query Language
PL/SQL is a block structured language that enables developers to combine the ...
PLSQL.pptx
PLSql.pptx
SQL Programming in database Management System
Pl sql chapter 1
PL_SQL, Trigger, Cursor, Stored procedure ,function
Introduction to PLSQL.PPT
Chapter 1
Lecture Notes Unit5 chapter 15 PL/SQL Programming
RDBMS - UNIT 4.pdf,UNIT THREE AND UNIT FIVE
Cursores.ppt
Oracle pl sql

More from nikhilsh66131 (7)

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
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Computing-Curriculum for Schools in Ghana
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Basic Mud Logging Guide for educational purpose
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Institutional Correction lecture only . . .
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Sports Quiz easy sports quiz sports quiz
Anesthesia in Laparoscopic Surgery in India
Computing-Curriculum for Schools in Ghana
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharma ospi slides which help in ospi learning
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Basic Mud Logging Guide for educational purpose
Module 4: Burden of Disease Tutorial Slides S2 2025
Institutional Correction lecture only . . .
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
FourierSeries-QuestionsWithAnswers(Part-A).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