SlideShare une entreprise Scribd logo
1  sur  9
1 Using ORACLE® Introduction to PL/SQL
DATA DEFINATION LANGUAGE Oracle Engine PL/SQL ENGINE: 2 PL/SQL stands for Procedural Extension to Structured Query Language. PL /SQL support is provided in Oracle from versions > 6; PL/SQL is used to provide users with the ability to use variables, loops , function etc in the database. SQL can be combined easily into the PL/SQL code .Since the PL/SQL program is processed by the PL/SQL Statement Executor ,it reduces the load on Oracle thus making it perform  faster.
3 Anonymous Block PL/SQL uses a block structure hence making it easier to write and maintain code. PL/SQL provides us with the following: Variables and constants. Loops and conditional constructs. Functions and Procedure that enable code reusability. Exception handling . The Anonymous Block ,the basic PL/SQL code is as follows: 	<<label>> 		 [ DECLARE  ] 		TYPE / item / FUNCTION / PROCEDURE declarations or variables. 		BEGIN  			Statements  (both SQL and PL/SQL) 		 [ EXCEPTION  ] 		EXCEPTION handlers to handle the exception 		END label;
4 Anonymous Block Let us write an example Anonymous block. DECLARE name  varchar2[20]; BEGIN name := ‘Larry’; DBMS_OUTPUT.PUT_LINE(‘The name is : ‘ || name); END The above anonymous block print the name ‘Larry'. Key points to be highlighted here are: The variable name must follow rules similar to that of declaring Tables in SQL and the data type with size be mentioned. The := operator is the assignment operator in PL/SQL. The DBMS_OUTPUT.PUT_LINE prints text enclosed in ( ) .Here we use a ‘||’ concatenation operator to join the string and variable.
5 Variables The various data types in PL/SQL are : LOB refers to large object. It could be of the type BINARY LARGE OBJECT (BLOB) or CHARACTER LARGE OBJECT (CLOB) to store image or audio in binary format (BLOB) or a text file (CLOB) up to the size of 4 GIGABYTES. BFILE refers to an external file to be stored in a database. 	A variable must be declared in the “DECLARE” block as: 		VARIABLE_NAME  	DATATYPE[SIZE]; 	A variable may be initialized when declared (otherwise set to NULL) 	 VARIABLE_NAME  	DATATYPE[SIZE]:= VALUE;    We may also define a variable to not hold null values. 	 VARIABLE_NAME  	DATATYPE[SIZE]     NOT NULL := VALUE;
6 %TYPE and %ROWTYPE  We can declare a variable to have a data type of any column or another variable using the  %TYPE attribute which is prefixed with the table and column or variable name. SYNTAX: 	VARIABLE _NAME TABLE_NAME.COLUMN_NAME[VARIABLE_NAME]%TYPE ; EXAMPLE: 	name    InfoTable.name%TYPE; The %ROWTYPE attribute is used to declare a variable to hold an entire row which is a collection of multiple columns of a table. SYNTAX: 		VARIABLE _NAME TABLE_NAME %ROWTYPE EXAMPLE: 		name  InfoTable%ROWTYPE;
7 BIND/HOST VARIABLES Bind variables are the variables that are created in the host environment hence also called as host variable. The features of a bind variable are: Unlike normal variables the memory used by a bind variable is not cleared when the PL/SQL block execution is complete. Can be accessed outside the block by other PL/SQL and SQL code. Declared using a VARIABLE keyword and above the “DECLARE” block. While usage they are referred wit a prefixed : symbol SYNTAX: VARIABLE variable_name DATATYPE[SIZE]; EXAMPLE: VARIABLE eage NUMBER; 		BEGIN 		SELECT age INTO  :eage  FROM InfoTable WHERE name = ‘bill’; 		END 		Only character array variables need to be given a size.
8 Substitution Variables We can either hard code the values of variable or accept the values from the user. To accept a value from the user , it has to be declared as a SUBSTITUTION VARIABLE. Substitution variables when used accept value from user. SYNTAX: VARIABLE variable_name DATATYPE[SIZE] := &variable_name; EXAMPLE : VARIABLE age NUMBER; 	DECLARE ename VARCHAR(20)  := &ename; 	BEGIN 	SELECT age INTO eage FRM InfoTable WHERE name = ename; 	END;
THANK YOU 9 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit:   www.dataminingtools.net

Contenu connexe

Tendances

Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
Prabu Cse
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
Belle Wx
 

Tendances (20)

SQL
SQLSQL
SQL
 
Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Packages - PL/SQL
Packages - PL/SQLPackages - PL/SQL
Packages - PL/SQL
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02Oracle - Program with PL/SQL - Lession 02
Oracle - Program with PL/SQL - Lession 02
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
Dynamic websites lec3
Dynamic websites lec3Dynamic websites lec3
Dynamic websites lec3
 
Oracle Baisc Tutorial
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorial
 
Cursors
CursorsCursors
Cursors
 
8. sql
8. sql8. sql
8. sql
 

En vedette

hoja de vida de Estefania Gaviria Escalante
hoja de vida de Estefania Gaviria Escalantehoja de vida de Estefania Gaviria Escalante
hoja de vida de Estefania Gaviria Escalante
Andres Drummer
 
A model for profit pattern mining based on genetic algorithm
A model for profit pattern mining based on genetic algorithmA model for profit pattern mining based on genetic algorithm
A model for profit pattern mining based on genetic algorithm
eSAT Journals
 
Project Initiation Document
Project Initiation DocumentProject Initiation Document
Project Initiation Document
Faraaz Gani
 

En vedette (20)

Ingreso a wiki
Ingreso a wikiIngreso a wiki
Ingreso a wiki
 
hoja de vida de Estefania Gaviria Escalante
hoja de vida de Estefania Gaviria Escalantehoja de vida de Estefania Gaviria Escalante
hoja de vida de Estefania Gaviria Escalante
 
Resume_Altaf
Resume_AltafResume_Altaf
Resume_Altaf
 
Web2.0
Web2.0Web2.0
Web2.0
 
CV_RAULT-Alexis
CV_RAULT-AlexisCV_RAULT-Alexis
CV_RAULT-Alexis
 
How to present a new piece of language
How to present a new piece of languageHow to present a new piece of language
How to present a new piece of language
 
Master reports vers 2015 2
Master reports vers 2015 2Master reports vers 2015 2
Master reports vers 2015 2
 
A model for profit pattern mining based on genetic algorithm
A model for profit pattern mining based on genetic algorithmA model for profit pattern mining based on genetic algorithm
A model for profit pattern mining based on genetic algorithm
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Le csfpt examine_une_nouvelle_serie_de_textes_-ppcr-_pour_clore_l-annee_2016
Le csfpt examine_une_nouvelle_serie_de_textes_-ppcr-_pour_clore_l-annee_2016Le csfpt examine_une_nouvelle_serie_de_textes_-ppcr-_pour_clore_l-annee_2016
Le csfpt examine_une_nouvelle_serie_de_textes_-ppcr-_pour_clore_l-annee_2016
 
Project Initiation Document
Project Initiation DocumentProject Initiation Document
Project Initiation Document
 
FlyScreen
FlyScreenFlyScreen
FlyScreen
 
Online Marketing
Online MarketingOnline Marketing
Online Marketing
 
Fizik Tingkatan 5: Pembiasan
Fizik Tingkatan 5:  PembiasanFizik Tingkatan 5:  Pembiasan
Fizik Tingkatan 5: Pembiasan
 
Screenless display
Screenless displayScreenless display
Screenless display
 
HRD trends 2011
HRD trends 2011HRD trends 2011
HRD trends 2011
 
Modelo do dossiê 2013
Modelo do dossiê 2013Modelo do dossiê 2013
Modelo do dossiê 2013
 
Top 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applicationsTop 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applications
 
Streaming architecture patterns
Streaming architecture patternsStreaming architecture patterns
Streaming architecture patterns
 
SCREENLESS DISPLAY
SCREENLESS DISPLAYSCREENLESS DISPLAY
SCREENLESS DISPLAY
 

Similaire à Oracle: PLSQL Introduction

Unit 4 rdbms study_material
Unit 4  rdbms study_materialUnit 4  rdbms study_material
Unit 4 rdbms study_material
gayaramesh
 
10g plsql slide
10g plsql slide10g plsql slide
10g plsql slide
Tanu_Manu
 

Similaire à Oracle: PLSQL Introduction (20)

Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Oracle etl openworld
Oracle etl openworldOracle etl openworld
Oracle etl openworld
 
Unit 4 rdbms study_material
Unit 4  rdbms study_materialUnit 4  rdbms study_material
Unit 4 rdbms study_material
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
 
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
 
Dbms 2011
Dbms 2011Dbms 2011
Dbms 2011
 
Unit 4 plsql
Unit 4  plsqlUnit 4  plsql
Unit 4 plsql
 
10g plsql slide
10g plsql slide10g plsql slide
10g plsql slide
 
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 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCROracle 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCR
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Oracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincrOracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincr
 
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-ch1
Pl sql-ch1Pl sql-ch1
Pl sql-ch1
 

Plus de oracle content (12)

Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oracle: Programs
Oracle: ProgramsOracle: Programs
Oracle: Programs
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Oracle: Control Structures
Oracle:  Control StructuresOracle:  Control Structures
Oracle: Control Structures
 
Oracle: Dw Design
Oracle: Dw DesignOracle: Dw Design
Oracle: Dw Design
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle Warehouse
Oracle WarehouseOracle Warehouse
Oracle Warehouse
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle: New Plsql
Oracle: New PlsqlOracle: New Plsql
Oracle: New Plsql
 
Oracle: Fundamental Of Dw
Oracle: Fundamental Of DwOracle: Fundamental Of Dw
Oracle: Fundamental Of Dw
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Oracle: PLSQL Introduction

  • 1. 1 Using ORACLE® Introduction to PL/SQL
  • 2. DATA DEFINATION LANGUAGE Oracle Engine PL/SQL ENGINE: 2 PL/SQL stands for Procedural Extension to Structured Query Language. PL /SQL support is provided in Oracle from versions > 6; PL/SQL is used to provide users with the ability to use variables, loops , function etc in the database. SQL can be combined easily into the PL/SQL code .Since the PL/SQL program is processed by the PL/SQL Statement Executor ,it reduces the load on Oracle thus making it perform faster.
  • 3. 3 Anonymous Block PL/SQL uses a block structure hence making it easier to write and maintain code. PL/SQL provides us with the following: Variables and constants. Loops and conditional constructs. Functions and Procedure that enable code reusability. Exception handling . The Anonymous Block ,the basic PL/SQL code is as follows: <<label>> [ DECLARE ] TYPE / item / FUNCTION / PROCEDURE declarations or variables. BEGIN Statements (both SQL and PL/SQL) [ EXCEPTION ] EXCEPTION handlers to handle the exception END label;
  • 4. 4 Anonymous Block Let us write an example Anonymous block. DECLARE name varchar2[20]; BEGIN name := ‘Larry’; DBMS_OUTPUT.PUT_LINE(‘The name is : ‘ || name); END The above anonymous block print the name ‘Larry'. Key points to be highlighted here are: The variable name must follow rules similar to that of declaring Tables in SQL and the data type with size be mentioned. The := operator is the assignment operator in PL/SQL. The DBMS_OUTPUT.PUT_LINE prints text enclosed in ( ) .Here we use a ‘||’ concatenation operator to join the string and variable.
  • 5. 5 Variables The various data types in PL/SQL are : LOB refers to large object. It could be of the type BINARY LARGE OBJECT (BLOB) or CHARACTER LARGE OBJECT (CLOB) to store image or audio in binary format (BLOB) or a text file (CLOB) up to the size of 4 GIGABYTES. BFILE refers to an external file to be stored in a database. A variable must be declared in the “DECLARE” block as: VARIABLE_NAME DATATYPE[SIZE]; A variable may be initialized when declared (otherwise set to NULL) VARIABLE_NAME DATATYPE[SIZE]:= VALUE; We may also define a variable to not hold null values. VARIABLE_NAME DATATYPE[SIZE] NOT NULL := VALUE;
  • 6. 6 %TYPE and %ROWTYPE We can declare a variable to have a data type of any column or another variable using the %TYPE attribute which is prefixed with the table and column or variable name. SYNTAX: VARIABLE _NAME TABLE_NAME.COLUMN_NAME[VARIABLE_NAME]%TYPE ; EXAMPLE: name InfoTable.name%TYPE; The %ROWTYPE attribute is used to declare a variable to hold an entire row which is a collection of multiple columns of a table. SYNTAX: VARIABLE _NAME TABLE_NAME %ROWTYPE EXAMPLE: name InfoTable%ROWTYPE;
  • 7. 7 BIND/HOST VARIABLES Bind variables are the variables that are created in the host environment hence also called as host variable. The features of a bind variable are: Unlike normal variables the memory used by a bind variable is not cleared when the PL/SQL block execution is complete. Can be accessed outside the block by other PL/SQL and SQL code. Declared using a VARIABLE keyword and above the “DECLARE” block. While usage they are referred wit a prefixed : symbol SYNTAX: VARIABLE variable_name DATATYPE[SIZE]; EXAMPLE: VARIABLE eage NUMBER; BEGIN SELECT age INTO :eage FROM InfoTable WHERE name = ‘bill’; END Only character array variables need to be given a size.
  • 8. 8 Substitution Variables We can either hard code the values of variable or accept the values from the user. To accept a value from the user , it has to be declared as a SUBSTITUTION VARIABLE. Substitution variables when used accept value from user. SYNTAX: VARIABLE variable_name DATATYPE[SIZE] := &variable_name; EXAMPLE : VARIABLE age NUMBER; DECLARE ename VARCHAR(20) := &ename; BEGIN SELECT age INTO eage FRM InfoTable WHERE name = ename; END;
  • 9. THANK YOU 9 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit: www.dataminingtools.net