SlideShare a Scribd company logo
Prepared By JAVATECH Search us in The World
1
Mar. 30
PLSQL CURSOR
Cursor is a pointer, used to point individual rows in the table. It is associated each
rows from the database table. If we want to perform any operation on individual
rows from the table, we use cursor. Cursor contains more than one rows or single
which returns from sql statements. They are created by default when any DML
(inser, update and delete) operation performed on database. It is used to check
DML operation in database successful performed or not.
E.g.
Single row contains
Cursor c1 is select * from stude where roll=1;
Above cursor name ‘c1’ which contains one record of roll no. 1.
Multi Rows Contains
Cursor c1 is select * from student;
Above we have not specify condition so Cursor ‘c1’ contains all rows from table
student.
Cursor are two types
1. Implicit cursor
2. Explicit Cursor
Discuss about Implicit Cursor
No need to declare cursor keywords. Sql statements are executed in
personal sql work area. Cursor are used to point that work area
implicitly(Automatically). Then question is how we know that whether it points to
rows or not. For that to check from table we use some attributes of cursor.
Prepared By JAVATECH Search us in The World
2
Mar. 30
Attributes of Implicit Cursor
1. %Found :-It is Boolean attributes which returns either true or false. If recent
sql statement affects single row or multiple rows then it returns true.
2. %NotFound:- It is opposite to %Found attribute. If recent sql statement
doesn’t affect any rows it returns true.
3. %IsOpen :- Though it is Implicit cursor so after executed it automatically
closed immediate. If you use %IsOpen attribute it always returns false.
Because before IsOpen attributes cursor is already closed.
4. %RowCount:- It count number of rows affected in most recent sql
statements.
Discuss about Explicit Cursor
To keep control over the cursor we explicitly declared it with Cursor keyword. And
cursor should define in declaration statement. It is created with select statement,
that returns more than one rows or single rows.
Explicit Cursor declaration
Cursor c1 is select * from stude where roll=1; returns only one rows from table
Cursor c1 is select * from student; returns more thn one rows from table.
Following steps are used for Explicit cursor
1. Declare the cursor
2. Open the cursor
3. Fetching the cursor
4. Close the cursor
Prepared By JAVATECH Search us in The World
3
Mar. 30
Declare the cursor
The cursor declaration is specify in declare part of PLSQL. It is associated with
name and select statement.
E.g.
Declare
Cursor c1 is select roll,name,mark from student where roll=1;
Begin
End;
Above c1 is the name of cursor and that is stored single rows from table where
roll=1;
Open the cursor
Open cursor is used to active the cursor and after active it will allocate memory
for cursor. If it will not activate then it can’t fetch its value to specified variable.
E.g.
Open c1;
Fetching the Cursor
Fetching the cursor value to variable. It will fetch value from cursor at time one
row only. If you will not fetch then how you extract value from cursor.
E.g.
Fetch c1 into roll,name,mark;
After write above line you can find the value of cursor c1 populate(send) to roll,
name & mark variable.
Then You can extend your program like as
If mark > 30 then
Dbms_output.put_line(‘Student is passes’);
Prepared By JAVATECH Search us in The World
4
Mar. 30
Else
Dbms_output.put_line(‘Student is failed’);
End if;
Close Cursor
It is used to close the PLSQL cursor. After closed it free or de-allocate the
memory.
************STEPS ARE CLOSED*********
Difference Between Implicit Cursor & Explicit Cursor
SLNO Implicit Cursor Explicit Cursor
1 It automatically associated with
database Cursor
To take control over cursor we
declare it
2 No Need Cursor Keyword for declare It require declaration Like
“Cursor C1”
3 It can associated with Single/Multiple
Rows
It can associated with
Single/Multiple Rows
4 Though cursor has no name then to
check we use SQL keyword.
“SQL%Attribute” SQL%Found,
SQL%isOpen SQL%NotFound
SQL%RowCount
It has explicit cursor name c1. So
to check we use “C1%attribute”
C1%Found C1%NotFound
C1%IsOpen like this….
5 No required Requited Fetching
6 No Requied Required To Close
Prepared By JAVATECH Search us In the World
E.g. of Implicit Cursor. Remember it has no name and declaration. And to use
attributes of Implicit Cursor use the SQL keyword.
Prepared By JAVATECH Search us in The World
5
Mar. 30
Wap in PLSQL to delete given roll no which is not present in database. After DML
operation we can check status of DML operation by using Implicit cursor.
Wap in PLSQL to delete given roll no which is not present in database. After DML
operation we can check status of DML operation by using Explicit cursor.
Here we declare explicit cursor and follow 4 steps which previously defined. Read
it.
Prepared By JAVATECH Search us in The World
6
Mar. 30
Wap In PLSQL to display all rows from table by using Explicit cursor.
Prepared By JAVATECH Search us in The World
7
Mar. 30
SEE ALL NETWORKING PROGRAM AND NOTES
VISIT OUR PAGE IN FACEBOOK “JAVATECH 123”
VISIT OUR NEXT SLIDE EXCEPTION IN PLSQL
***************THANKING YOU************

More Related Content

What's hot

Packages in PL/SQL
Packages in PL/SQLPackages in PL/SQL
Packages in PL/SQL
Pooja Dixit
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
exception handling
exception handlingexception handling
exception handling
rajshreemuthiah
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Edureka!
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
Nick Buytaert
 
Java package
Java packageJava package
Java package
CS_GDRCST
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
Mindfire Solutions
 
JAVA FEATURES
JAVA FEATURESJAVA FEATURES
JAVA FEATURES
shalinikarunakaran1
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
Swapnali Pawar
 
Exception Handling
Exception Handling Exception Handling
Exception Handling
Swapnali Pawar
 
Java Collections
Java CollectionsJava Collections
Java Collectionsparag
 
PL-SQL, Cursors & Triggers
PL-SQL, Cursors & TriggersPL-SQL, Cursors & Triggers
PL-SQL, Cursors & Triggers
Shalabh Chaudhary
 
Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
Umair Shakir
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
Md. Tanvir Hossain
 
Java and its features
Java and its featuresJava and its features
Java and its features
Pydi Nikhil
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
Anul Chaudhary
 

What's hot (20)

Packages in PL/SQL
Packages in PL/SQLPackages in PL/SQL
Packages in PL/SQL
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
exception handling
exception handlingexception handling
exception handling
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
Java package
Java packageJava package
Java package
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
 
JAVA FEATURES
JAVA FEATURESJAVA FEATURES
JAVA FEATURES
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Exception Handling
Exception Handling Exception Handling
Exception Handling
 
Java Collections
Java CollectionsJava Collections
Java Collections
 
PL-SQL, Cursors & Triggers
PL-SQL, Cursors & TriggersPL-SQL, Cursors & Triggers
PL-SQL, Cursors & Triggers
 
Java threads
Java threadsJava threads
Java threads
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Hibernate notes
Hibernate notesHibernate notes
Hibernate notes
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 

Similar to PLSQL CURSOR

Cursors in oracle
Cursors in oracleCursors in oracle
Cursors in oracleTamizhmuhil
 
plsql tutorialhub....
plsql tutorialhub....plsql tutorialhub....
plsql tutorialhub....Abhiram Vijay
 
Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06
Thuan Nguyen
 
Cursors
CursorsCursors
PLSQL Note
PLSQL NotePLSQL Note
PLSQL Note
Arun Sial
 
PL/SQL - CURSORS
PL/SQL - CURSORSPL/SQL - CURSORS
PL/SQL - CURSORS
IshaRana14
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
DataminingTools Inc
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
oracle content
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
Dhilip Prakash
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
Dhilip Prakash
 
PLSQL
PLSQLPLSQL
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-onlyAshwin Kumar
 
4 cursors
4 cursors4 cursors
4 cursors
Babajan Baig
 
Cursors.ppt
Cursors.pptCursors.ppt
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
LakshmiSamivel
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
Suhel Firdus
 
Triggers n Cursors.ppt
Triggers n Cursors.pptTriggers n Cursors.ppt
Triggers n Cursors.ppt
VADAPALLYPRAVEENKUMA1
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
srijanani2030
 

Similar to PLSQL CURSOR (20)

Cursors in oracle
Cursors in oracleCursors in oracle
Cursors in oracle
 
plsql tutorialhub....
plsql tutorialhub....plsql tutorialhub....
plsql tutorialhub....
 
Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06
 
Cursors
CursorsCursors
Cursors
 
Cursors
CursorsCursors
Cursors
 
PLSQL Note
PLSQL NotePLSQL Note
PLSQL Note
 
PL/SQL - CURSORS
PL/SQL - CURSORSPL/SQL - CURSORS
PL/SQL - CURSORS
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
PLSQL
PLSQLPLSQL
PLSQL
 
3963066 pl-sql-notes-only
3963066 pl-sql-notes-only3963066 pl-sql-notes-only
3963066 pl-sql-notes-only
 
4 cursors
4 cursors4 cursors
4 cursors
 
Cursors.ppt
Cursors.pptCursors.ppt
Cursors.ppt
 
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
 
Basic cursors in oracle
Basic cursors in oracleBasic cursors in oracle
Basic cursors in oracle
 
Triggers n Cursors.ppt
Triggers n Cursors.pptTriggers n Cursors.ppt
Triggers n Cursors.ppt
 
Module07
Module07Module07
Module07
 
SQL / PL
SQL / PLSQL / PL
SQL / PL
 

Recently uploaded

Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 

Recently uploaded (20)

Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 

PLSQL CURSOR

  • 1. Prepared By JAVATECH Search us in The World 1 Mar. 30 PLSQL CURSOR Cursor is a pointer, used to point individual rows in the table. It is associated each rows from the database table. If we want to perform any operation on individual rows from the table, we use cursor. Cursor contains more than one rows or single which returns from sql statements. They are created by default when any DML (inser, update and delete) operation performed on database. It is used to check DML operation in database successful performed or not. E.g. Single row contains Cursor c1 is select * from stude where roll=1; Above cursor name ‘c1’ which contains one record of roll no. 1. Multi Rows Contains Cursor c1 is select * from student; Above we have not specify condition so Cursor ‘c1’ contains all rows from table student. Cursor are two types 1. Implicit cursor 2. Explicit Cursor Discuss about Implicit Cursor No need to declare cursor keywords. Sql statements are executed in personal sql work area. Cursor are used to point that work area implicitly(Automatically). Then question is how we know that whether it points to rows or not. For that to check from table we use some attributes of cursor.
  • 2. Prepared By JAVATECH Search us in The World 2 Mar. 30 Attributes of Implicit Cursor 1. %Found :-It is Boolean attributes which returns either true or false. If recent sql statement affects single row or multiple rows then it returns true. 2. %NotFound:- It is opposite to %Found attribute. If recent sql statement doesn’t affect any rows it returns true. 3. %IsOpen :- Though it is Implicit cursor so after executed it automatically closed immediate. If you use %IsOpen attribute it always returns false. Because before IsOpen attributes cursor is already closed. 4. %RowCount:- It count number of rows affected in most recent sql statements. Discuss about Explicit Cursor To keep control over the cursor we explicitly declared it with Cursor keyword. And cursor should define in declaration statement. It is created with select statement, that returns more than one rows or single rows. Explicit Cursor declaration Cursor c1 is select * from stude where roll=1; returns only one rows from table Cursor c1 is select * from student; returns more thn one rows from table. Following steps are used for Explicit cursor 1. Declare the cursor 2. Open the cursor 3. Fetching the cursor 4. Close the cursor
  • 3. Prepared By JAVATECH Search us in The World 3 Mar. 30 Declare the cursor The cursor declaration is specify in declare part of PLSQL. It is associated with name and select statement. E.g. Declare Cursor c1 is select roll,name,mark from student where roll=1; Begin End; Above c1 is the name of cursor and that is stored single rows from table where roll=1; Open the cursor Open cursor is used to active the cursor and after active it will allocate memory for cursor. If it will not activate then it can’t fetch its value to specified variable. E.g. Open c1; Fetching the Cursor Fetching the cursor value to variable. It will fetch value from cursor at time one row only. If you will not fetch then how you extract value from cursor. E.g. Fetch c1 into roll,name,mark; After write above line you can find the value of cursor c1 populate(send) to roll, name & mark variable. Then You can extend your program like as If mark > 30 then Dbms_output.put_line(‘Student is passes’);
  • 4. Prepared By JAVATECH Search us in The World 4 Mar. 30 Else Dbms_output.put_line(‘Student is failed’); End if; Close Cursor It is used to close the PLSQL cursor. After closed it free or de-allocate the memory. ************STEPS ARE CLOSED********* Difference Between Implicit Cursor & Explicit Cursor SLNO Implicit Cursor Explicit Cursor 1 It automatically associated with database Cursor To take control over cursor we declare it 2 No Need Cursor Keyword for declare It require declaration Like “Cursor C1” 3 It can associated with Single/Multiple Rows It can associated with Single/Multiple Rows 4 Though cursor has no name then to check we use SQL keyword. “SQL%Attribute” SQL%Found, SQL%isOpen SQL%NotFound SQL%RowCount It has explicit cursor name c1. So to check we use “C1%attribute” C1%Found C1%NotFound C1%IsOpen like this…. 5 No required Requited Fetching 6 No Requied Required To Close Prepared By JAVATECH Search us In the World E.g. of Implicit Cursor. Remember it has no name and declaration. And to use attributes of Implicit Cursor use the SQL keyword.
  • 5. Prepared By JAVATECH Search us in The World 5 Mar. 30 Wap in PLSQL to delete given roll no which is not present in database. After DML operation we can check status of DML operation by using Implicit cursor. Wap in PLSQL to delete given roll no which is not present in database. After DML operation we can check status of DML operation by using Explicit cursor. Here we declare explicit cursor and follow 4 steps which previously defined. Read it.
  • 6. Prepared By JAVATECH Search us in The World 6 Mar. 30 Wap In PLSQL to display all rows from table by using Explicit cursor.
  • 7. Prepared By JAVATECH Search us in The World 7 Mar. 30 SEE ALL NETWORKING PROGRAM AND NOTES VISIT OUR PAGE IN FACEBOOK “JAVATECH 123” VISIT OUR NEXT SLIDE EXCEPTION IN PLSQL ***************THANKING YOU************