You are on page 1of 13

A

Micro Project
on
Cursor
Submitted in partial fulfillment of the requirement for the award of
Diploma of Engineering
in
Computer Engineering
By
Priyanka Dhuri
Omkar Vengurlekar
Siddhi Hate
Aarchay Parekh
Pritam Chavan

under the guidance of


Prof. Akshata Raut

Department of Computer Engineering


December 2021
CERTIFICATE

VIVA COLLEGE OF DIPLOMA ENGINEERING &


TECHNOLOGY
VIRAR (W)
2021-22
This is to certify that the micro project entitled “Cursor” has been submitted
under the guidance of Akshata Raut in partial fulfillment of the requirement for
the award of Diploma of Engineering in Computer Engineering from
Maharashtra State Board of Technical Education.

“Cursor”
GROUP MEMBERS
Roll no.76 Priyanka Dhuri
Roll no.77 Omkar Vengurlekar
Roll no.78 Siddhi Hate
Roll no.79 Aarchay Parekh
Roll no.80 Pritam Chavan

Project Guide H.O.D


Mrs. Akshata raut Mr. Nikhil Asolkar
INDEX

Sr. No. Name of the topic Page no.


PART –A PLAN

1 Brief Introduction 1

2 Aim of the Micro-Project 1

3 Action Plan 2

4 Resources Required 2
PART –B OUTCOMES

1 Brief Description 3

2 Aim of Micro-Project 4

3 Course Outcomes Integrated 4

4 Actual Procedure Followed 5

5 Actual Resources Used 6

6 Outputs of the Micro-Projects 7

7 Skill Developed/ learning out of this Micro-Project 8


Curso ‘ DMS22319 – Sem
r III

PART A- ACTION PLAN

Brief Introduction

A cursor is a temporary work area created in the system memory when a SQL statement is
executed. A cursor contains information on a select statement and the rows of data accessed
by it. This temporary work area is used to store the data retrieved from the database, and
manipulate this data. A cursor can hold more than one row, but can process only one row at a
time. The set of rows the cursor holds is called the active set.
There are two types of cursors in PL/SQL :
1. Implicit cursors.
2. Explicit cursors.

Aim of the Micro-project

To run implicit cursors and explicit cursors properly.

VIVA COLLEGE OF DIPLOMA AND ENGG, COMPUTER ENGG 1


Resource Required

Sr. Name of Specifications Quantity


No. Resource

1 Hardware: Computer(i3-i5 preferable), RAM minimum 2GB


computer system and onwards and HDD minimum 5 GB
As per batch
2 Operating system Windows XP/ size
Windows 7/LINUX version 5.0 or later

3 software Oracle/MySQL Server 2005/2008/2011


PART –B OUTCOMES

Brief Description

A cursor is a temporary work area created in the system memory when a SQL statement is
executed. A cursor contains information on a select statement and the rows of data accessed
by it. This temporary work area is used to store the data retrieved from the database, and
manipulate this data. A cursor can hold more than one row, but can process only one row at a
time. The set of rows the cursor holds is called the active set.
There are two types of cursors in PL/SQL :

1. Implicit cursors.
2. Explicit cursors.

Both implicit and explicit cursors have the same functionality, but they differ in the way
they are accessed.

Implicit cursors :

These are created by default when DML statements like, INSERT, UPDATE, and
DELETE statements are executed. They are also created when a SELECT statement that
returns just one row is executed.
When you execute DML statements like DELETE, INSERT, UPDATE and SELECT
statements, implicit statements are created to process these statements.
Oracle provides few attributes called as implicit cursor attributes to check the status of
DML operations. The cursor attributes available are %FOUND, %NOTFOUND,
%ROWCOUNT, and %ISOPEN.
For example, When you execute INSERT, UPDATE, or DELETE statements the cursor
attributes tell us whether any rows are affected and how many have been
affected. When a SELECT... INTO statement is executed in a PL/SQL Block, implicit cursor
attributes can be used to find out whether any row has been returned by the SELECT statement.
PL/SQL returns an error when no data is selected.

Explicit Cursors :

They must be created when you are executing a SELECT statement that returns more than
one row. Even though the cursor stores multiple records, only one record can be processed at
a time, which is called as current row. When you fetch a row the current row position moves
to next row.
An explicit cursor is defined in the declaration section of the PL/SQL Block. It is created on
a SELECT Statement which returns more than one row. We can provide a suitable name for
the cursor.

Aim of the Micro-project

To run implicit cursors and explicit cursors properly.


Course outcome (CO)

1. Write PL/SQL code for given database.

2. Apply triggers ob database also create procedure and functions according to


condition.

Actual Procedure Followed

1. Declaration of cursor.
2. Open the cursor .
3. Fetch data from the cursor one row at time into memory variable.
4. Exit from the loop after processing is complete.
5. Close the cursor.
Create table:

create table empsal(eid number(2),ename varchar2(20),dept varchar2(20),salary


number(10));
insert into empsal values(14, ’Gopal’, ’EXTC’, 20000);

select * from empsal;


Explicit Cursor:

declare
id empsal.eid%type;
name empsal.ename%type;
department empsal.dept%type; sal
empsal.salary%type;
cursor c_salary is select eid,ename,dept,salary from empsal where dept='Computer';
begin
open c_salary;
loop
fetch c_salary into id,name,department,sal; exit
when c_salary%notfound;
dbms_output.put_line(id||’ ’||name||’ ‘||department||’ ‘||sal); end
loop;
close c_salary;
end;
Implict cursor:

declare
total_rows number(10);
begin
update empsal set salary=salary + (15*salary)/100 where dept=’Computer’; if sql
%notfound then
dbms_output.put_line(‘No Employee’);
elsif sql%found then total_rows:=sql
%rowcount;
dbms_output.put_line(total_rows||’employee salary updated’); end
if;
end;
Actual Resources Used

Sr. Name of Specifications Quantity


No. Resource

1 Hardware: computer system Computer(i3-6th generation)

2 Operating system Windows10 1

3 software Oracle 10g express

Outputs of the Micro-Projects:


Skill Developed/ learning out of this Micro-Project:

Thus we have studied to run PL/SQL programs based on implict and explit cursor.

You might also like