SlideShare a Scribd company logo
1Using ORACLE®Introduction to PL/SQL
DATA DEFINATION LANGUAGEOracle EnginePL/SQL ENGINE:2PL/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.
3Anonymous BlockPL/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;
4Anonymous BlockLet us write an example Anonymous block.DECLAREname  varchar2[20];BEGINname := ‘Larry’;DBMS_OUTPUT.PUT_LINE(‘The name is : ‘ || name);ENDThe 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.
5VariablesThe 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 %ROWTYPEEXAMPLE:		name  InfoTable%ROWTYPE;
7BIND/HOST VARIABLESBind 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 : symbolSYNTAX: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.
8Substitution VariablesWe 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;	DECLAREename VARCHAR(20)  := &ename;	BEGIN	SELECT age INTO eage FRM InfoTable WHERE name = ename;	END;
THANK YOU9THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit:  www.dataminingtools.net

More Related Content

PPTX
Introduction to PL/SQL
PPT
Sql operators & functions 3
PPTX
Trigger in mysql
PPT
02 Writing Executable Statments
PPT
PL/SQL Introduction and Concepts
PPTX
Procedure and Functions in pl/sql
PPT
ORACLE PL SQL
PPTX
5. stored procedure and functions
Introduction to PL/SQL
Sql operators & functions 3
Trigger in mysql
02 Writing Executable Statments
PL/SQL Introduction and Concepts
Procedure and Functions in pl/sql
ORACLE PL SQL
5. stored procedure and functions

What's hot (20)

PPT
SQL subquery
PPT
PPTX
4. plsql
PPT
1 - Introduction to PL/SQL
PPTX
SQL - DML and DDL Commands
PPTX
Packages in PL/SQL
PPTX
Sql Functions And Procedures
PDF
Oracle SQL Basics
PPTX
Sql Objects And PL/SQL
PPT
Introduction to-sql
PDF
Triggers in SQL | Edureka
PPT
Mysql
PPTX
Basic sql Commands
PPT
DB2 Interview Questions - Part 1
PDF
Sql tutorial
PPTX
introdution to SQL and SQL functions
PPS
Procedures/functions of rdbms
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DOCX
Sql loader good example
SQL subquery
4. plsql
1 - Introduction to PL/SQL
SQL - DML and DDL Commands
Packages in PL/SQL
Sql Functions And Procedures
Oracle SQL Basics
Sql Objects And PL/SQL
Introduction to-sql
Triggers in SQL | Edureka
Mysql
Basic sql Commands
DB2 Interview Questions - Part 1
Sql tutorial
introdution to SQL and SQL functions
Procedures/functions of rdbms
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
Sql loader good example
Ad

Viewers also liked (20)

PPTX
ORACLE PL SQL FOR BEGINNERS
PPTX
PL/SQL Fundamentals I
PDF
Oracle sql & plsql
DOC
Best sql plsql material
PDF
Oracle sql tutorial
PPTX
Oracle database 12c new features
PPS
Oracle Database Overview
PPT
Basic cursors in oracle
PDF
Sub query_SQL
 
PDF
Introduction aux Triggers avec MySQL
PPT
10g plsql slide
PDF
Lesson 6 - Administering Linux System (2)
PPT
Linux+01
PDF
Lesson 3 - Linux File System
PDF
Lesson 5 - Administering Linux System (1)
PDF
Lesson 1 - Introduction to Open Source & Linux
PDF
Lesson 7 - Linux Shell Programming
PDF
Lesson 8 - Reviewing Basic Networking
PDF
Lesson 2 - Install Linux & Command Line Environment
ORACLE PL SQL FOR BEGINNERS
PL/SQL Fundamentals I
Oracle sql & plsql
Best sql plsql material
Oracle sql tutorial
Oracle database 12c new features
Oracle Database Overview
Basic cursors in oracle
Sub query_SQL
 
Introduction aux Triggers avec MySQL
10g plsql slide
Lesson 6 - Administering Linux System (2)
Linux+01
Lesson 3 - Linux File System
Lesson 5 - Administering Linux System (1)
Lesson 1 - Introduction to Open Source & Linux
Lesson 7 - Linux Shell Programming
Lesson 8 - Reviewing Basic Networking
Lesson 2 - Install Linux & Command Line Environment
Ad

Similar to Oracle: PLSQL Introduction (20)

PPT
Chapter8 pl sql
PDF
rdbms.pdf plsql database system notes for students to study
PPTX
PL/SQL is a block structured language that enables developers to combine the ...
PDF
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
PDF
PDF
PDF
RDBMS - UNIT 4.pdf,UNIT THREE AND UNIT FIVE
DOC
Oracle etl openworld
PDF
Unit 4 rdbms study_material
PPT
Cursores.ppt
PDF
PL/SQL Complete Tutorial. All Topics Covered
PDF
Dbms 2011
PPTX
Ch as pbdasdadssadsadsadasdasdasdas fdt .pptx
PPTX
Unit 4 plsql
PPTX
PL SQL.pptx in computer language in database
DOCX
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
PDF
chapter 1.pdfbbbbbbbbbbbbbbbbbbbbbbbbbb
PDF
Oracle 11G Development Training noida Delhi NCR
PDF
Chapter8 pl sql
rdbms.pdf plsql database system notes for students to study
PL/SQL is a block structured language that enables developers to combine the ...
PROCEDURAL LANGUAGE/ STRUCTURED QUERY LANGUAGE.pdf
RDBMS - UNIT 4.pdf,UNIT THREE AND UNIT FIVE
Oracle etl openworld
Unit 4 rdbms study_material
Cursores.ppt
PL/SQL Complete Tutorial. All Topics Covered
Dbms 2011
Ch as pbdasdadssadsadsadasdasdasdas fdt .pptx
Unit 4 plsql
PL SQL.pptx in computer language in database
What does PL_SQL stand for and what is the functioning of PL_SQL.docx
chapter 1.pdfbbbbbbbbbbbbbbbbbbbbbbbbbb
Oracle 11G Development Training noida Delhi NCR

More from DataminingTools Inc (20)

PPTX
Terminology Machine Learning
PPTX
Techniques Machine Learning
PPTX
Machine learning Introduction
PPTX
Areas of machine leanring
PPTX
AI: Planning and AI
PPTX
AI: Logic in AI 2
PPTX
AI: Logic in AI
PPTX
AI: Learning in AI 2
PPTX
AI: Learning in AI
PPTX
AI: Introduction to artificial intelligence
PPTX
AI: Belief Networks
PPTX
AI: AI & Searching
PPTX
AI: AI & Problem Solving
PPTX
Data Mining: Text and web mining
PPTX
Data Mining: Outlier analysis
PPTX
Data Mining: Mining stream time series and sequence data
PPTX
Data Mining: Mining ,associations, and correlations
PPTX
Data Mining: Graph mining and social network analysis
PPTX
Data warehouse and olap technology
PPTX
Data Mining: Data processing
Terminology Machine Learning
Techniques Machine Learning
Machine learning Introduction
Areas of machine leanring
AI: Planning and AI
AI: Logic in AI 2
AI: Logic in AI
AI: Learning in AI 2
AI: Learning in AI
AI: Introduction to artificial intelligence
AI: Belief Networks
AI: AI & Searching
AI: AI & Problem Solving
Data Mining: Text and web mining
Data Mining: Outlier analysis
Data Mining: Mining stream time series and sequence data
Data Mining: Mining ,associations, and correlations
Data Mining: Graph mining and social network analysis
Data warehouse and olap technology
Data Mining: Data processing

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
KodekX | Application Modernization Development
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Reach Out and Touch Someone: Haptics and Empathic Computing
MIND Revenue Release Quarter 2 2025 Press Release
sap open course for s4hana steps from ECC to s4
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Review of recent advances in non-invasive hemoglobin estimation

Oracle: PLSQL Introduction

  • 2. DATA DEFINATION LANGUAGEOracle EnginePL/SQL ENGINE:2PL/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. 3Anonymous BlockPL/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. 4Anonymous BlockLet us write an example Anonymous block.DECLAREname varchar2[20];BEGINname := ‘Larry’;DBMS_OUTPUT.PUT_LINE(‘The name is : ‘ || name);ENDThe 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. 5VariablesThe 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 %ROWTYPEEXAMPLE: name InfoTable%ROWTYPE;
  • 7. 7BIND/HOST VARIABLESBind 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 : symbolSYNTAX: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. 8Substitution VariablesWe 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; DECLAREename VARCHAR(20) := &ename; BEGIN SELECT age INTO eage FRM InfoTable WHERE name = ename; END;
  • 9. THANK YOU9THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit: www.dataminingtools.net