SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
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 (20)

PDF
Packages - PL/SQL
Esmita Gupta
 
PPT
PLSQL Cursors
spin_naresh
 
PPT
Chapter8 pl sql
Jafar Nesargi
 
PPTX
PL/SQL - CURSORS
IshaRana14
 
PPTX
PLSQL Tutorial
Quang Minh Đoàn
 
PPTX
Procedure and Functions in pl/sql
Ñirmal Tatiwal
 
PDF
Nested Queries Lecture
Felipe Costa
 
PPTX
4. plsql
Amrit Kaur
 
PPTX
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
PPTX
Java string handling
Salman Khan
 
PPTX
Understanding isolation levels
Hieu Nguyen Trung
 
PPTX
Oracle: Control Structures
DataminingTools Inc
 
PPT
Cursors.ppt
Karthick Panneerselvam
 
PDF
Normalization in SQL | Edureka
Edureka!
 
PPTX
Trigger
VForce Infotech
 
PPTX
Inter Thread Communicationn.pptx
SelvakumarNSNS
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPSX
Exception Handling
Reddhi Basu
 
PPTX
Pure virtual function and abstract class
Amit Trivedi
 
PPTX
trigger dbms
kuldeep100
 
Packages - PL/SQL
Esmita Gupta
 
PLSQL Cursors
spin_naresh
 
Chapter8 pl sql
Jafar Nesargi
 
PL/SQL - CURSORS
IshaRana14
 
PLSQL Tutorial
Quang Minh Đoàn
 
Procedure and Functions in pl/sql
Ñirmal Tatiwal
 
Nested Queries Lecture
Felipe Costa
 
4. plsql
Amrit Kaur
 
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
Java string handling
Salman Khan
 
Understanding isolation levels
Hieu Nguyen Trung
 
Oracle: Control Structures
DataminingTools Inc
 
Normalization in SQL | Edureka
Edureka!
 
Inter Thread Communicationn.pptx
SelvakumarNSNS
 
07. Virtual Functions
Haresh Jaiswal
 
Exception Handling
Reddhi Basu
 
Pure virtual function and abstract class
Amit Trivedi
 
trigger dbms
kuldeep100
 

Similar to PLSQL CURSOR (20)

PPT
Cursors in oracle
Tamizhmuhil
 
PPTX
plsql tutorialhub....
Abhiram Vijay
 
PDF
Cursors
Isha Aggarwal
 
PDF
Lecture Notes Unit5 chapter19 Cursor in Pl/SQL
Murugan146644
 
PDF
PLSQL Note
Arun Sial
 
PPTX
Oracle: Cursors
DataminingTools Inc
 
PPTX
Oracle:Cursors
oracle content
 
PDF
Pl sql programme
Dhilip Prakash
 
PDF
Pl sql programme
Dhilip Prakash
 
PDF
PLSQL
Srinath Reddy
 
DOC
3963066 pl-sql-notes-only
Ashwin Kumar
 
PPT
4 cursors
Babajan Baig
 
PPT
Procedures andcursors
LakshmiSamivel
 
PPT
Basic cursors in oracle
Suhel Firdus
 
PPTX
BBarters_PL_SQL gives cdemo details.pptx
shailesh patil
 
PPT
Triggers n Cursors.ppt
VADAPALLYPRAVEENKUMA1
 
PPT
Module07
Sridhar P
 
PPT
SQL / PL
srijanani2030
 
PPT
Intro to tsql unit 13
Syed Asrarali
 
PPTX
PL SQL.pptx in computer language in database
ironman82715
 
Cursors in oracle
Tamizhmuhil
 
plsql tutorialhub....
Abhiram Vijay
 
Cursors
Isha Aggarwal
 
Lecture Notes Unit5 chapter19 Cursor in Pl/SQL
Murugan146644
 
PLSQL Note
Arun Sial
 
Oracle: Cursors
DataminingTools Inc
 
Oracle:Cursors
oracle content
 
Pl sql programme
Dhilip Prakash
 
Pl sql programme
Dhilip Prakash
 
3963066 pl-sql-notes-only
Ashwin Kumar
 
4 cursors
Babajan Baig
 
Procedures andcursors
LakshmiSamivel
 
Basic cursors in oracle
Suhel Firdus
 
BBarters_PL_SQL gives cdemo details.pptx
shailesh patil
 
Triggers n Cursors.ppt
VADAPALLYPRAVEENKUMA1
 
Module07
Sridhar P
 
SQL / PL
srijanani2030
 
Intro to tsql unit 13
Syed Asrarali
 
PL SQL.pptx in computer language in database
ironman82715
 
Ad

Recently uploaded (20)

PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Ad

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************