SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

02 Writing Executable Statments
02 Writing Executable Statments02 Writing Executable Statments
02 Writing Executable Statments
 
04 Handling Exceptions
04 Handling Exceptions04 Handling Exceptions
04 Handling Exceptions
 
08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata08 Dynamic SQL and Metadata
08 Dynamic SQL and Metadata
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 
Introduction to triggers
Introduction to triggersIntroduction to triggers
Introduction to triggers
 
Function & procedure
Function & procedureFunction & procedure
Function & procedure
 
pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql Procedure
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Chapter8 pl sql
Chapter8 pl sqlChapter8 pl sql
Chapter8 pl sql
 
4. plsql
4. plsql4. plsql
4. plsql
 
Introduction to PL/SQL
Introduction to PL/SQLIntroduction to PL/SQL
Introduction to PL/SQL
 
PL/SQL TRIGGERS
PL/SQL TRIGGERSPL/SQL TRIGGERS
PL/SQL TRIGGERS
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
plsql.ppt
plsql.pptplsql.ppt
plsql.ppt
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Sql Functions And Procedures
Sql Functions And ProceduresSql Functions And Procedures
Sql Functions And Procedures
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 

Destacado

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
honglee71
 
Introduction aux Triggers avec MySQL
Introduction aux Triggers avec MySQLIntroduction aux Triggers avec MySQL
Introduction aux Triggers avec MySQL
Rouff Joseph
 
10g plsql slide
10g plsql slide10g plsql slide
10g plsql slide
Tanu_Manu
 
Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)
Thang Man
 
Lesson 3 - Linux File System
Lesson 3 - Linux File SystemLesson 3 - Linux File System
Lesson 3 - Linux File System
Thang Man
 
Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)
Thang Man
 
Lesson 1 - Introduction to Open Source & Linux
Lesson 1 - Introduction to Open Source & LinuxLesson 1 - Introduction to Open Source & Linux
Lesson 1 - Introduction to Open Source & Linux
Thang Man
 
Lesson 7 - Linux Shell Programming
Lesson 7 - Linux Shell ProgrammingLesson 7 - Linux Shell Programming
Lesson 7 - Linux Shell Programming
Thang Man
 
Lesson 8 - Reviewing Basic Networking
Lesson 8 - Reviewing Basic NetworkingLesson 8 - Reviewing Basic Networking
Lesson 8 - Reviewing Basic Networking
Thang Man
 
Lesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line EnvironmentLesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line Environment
Thang Man
 

Destacado (20)

ORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERS
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
Oracle database 12c new features
Oracle database 12c new featuresOracle database 12c new features
Oracle database 12c new features
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
Plsql
PlsqlPlsql
Plsql
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
Sub query_SQL
Sub query_SQLSub query_SQL
Sub query_SQL
 
Introduction aux Triggers avec MySQL
Introduction aux Triggers avec MySQLIntroduction aux Triggers avec MySQL
Introduction aux Triggers avec MySQL
 
10g plsql slide
10g plsql slide10g plsql slide
10g plsql slide
 
Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)
 
Linux+01
Linux+01Linux+01
Linux+01
 
Lesson 3 - Linux File System
Lesson 3 - Linux File SystemLesson 3 - Linux File System
Lesson 3 - Linux File System
 
Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)
 
Subqueries
SubqueriesSubqueries
Subqueries
 
Lesson 1 - Introduction to Open Source & Linux
Lesson 1 - Introduction to Open Source & LinuxLesson 1 - Introduction to Open Source & Linux
Lesson 1 - Introduction to Open Source & Linux
 
Lesson 7 - Linux Shell Programming
Lesson 7 - Linux Shell ProgrammingLesson 7 - Linux Shell Programming
Lesson 7 - Linux Shell Programming
 
Lesson 8 - Reviewing Basic Networking
Lesson 8 - Reviewing Basic NetworkingLesson 8 - Reviewing Basic Networking
Lesson 8 - Reviewing Basic Networking
 
Lesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line EnvironmentLesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line Environment
 

Similar a Oracle: PLSQL Introduction

Unit 4 rdbms study_material
Unit 4  rdbms study_materialUnit 4  rdbms study_material
Unit 4 rdbms study_material
gayaramesh
 

Similar a Oracle: PLSQL Introduction (20)

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
 
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
 
Pl sql chapter 1
Pl sql chapter 1Pl sql chapter 1
Pl sql chapter 1
 
Dynamic websites lec3
Dynamic websites lec3Dynamic websites lec3
Dynamic websites lec3
 

Más de DataminingTools Inc

Más de DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

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