Ankit Vashisth
Ankit Vashisth
Ankit Vashisth
WORKSHEET 3
1. Aim:
i. Write a Pl Sql code to retrieve the reports from the employee table and
display them using cursors.
ii. Write a Program in Pl Sql to fetch single record and single column from a
table.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
(i) Write a Pl Sql code to retrieve the reports from the employee table and
display them using cursors.
DECLARE
Emp_id INTEGER;
first_name VARCHAR(50);
last_name VARCHAR(50);
email VARCHAR(100);
phone INTEGER;
hire_date DATE; job_id
VARCHAR(50); salary
INTEGER; manager_id
INTEGER; dept_id
INTEGER; CURSOR
emp_cursor IS
SELECT empid, first_name, last_name, email, phone, hire_date, job_id, salary,
manager_id, dept_id from employee;
BEGIN
OPEN emp_cursor;
LOOP
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
(ii) Write a Program in Pl Sql to fetch single record and single column
from a table.
DECLARE
CURSOR employee_cursor IS
SELECT * FROM employee;
employee_record employee_cursor%ROWTYPE;
BEGIN
OPEN employee_cursor;
LOOP
FETCH employee_cursor INTO employee_record;
EXIT WHEN employee_cursor%NOTFOUND;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
3. Learning Outcomes
(i) We learnt the basics of DBMS(DataBases).
(ii) We learnt to use PL-SQl(procedural language) code.
(iii) We learnt the use of cursors and views.