Exercise 11 DBMS
Exercise 11 DBMS
AIM:
Write a block in PL/SQL to create a Cursor that displays the employee name and number of jobs he or
she has done in the past.
PROCEDURE
1. Create a employee table with id, name, past work, present work
2. Create an explicit courser
3. Write select statements within courser
4. Open , Fetch and Close courser
PL/SQL COMMADS :
DECLARE
empId number(4);
empName varchar2(30);
empPastWork varchar2(30);
CURSOR Past_Works IS
from Employee_table;
BEGIN
OPEN Past_Works;
LOOP
END LOOP;
CLOSE Past_Works;
END;
OUTPUT:
Table created
4 rows selected.
Statement processed.
123 Althaf Clerk
121 Mahesh Engineer
122 AbhiRam Team Lead
141 Sree Architect
141 Sree Architect
11b:
Aim:
To Write a program in PL/SQL to create a cursor to display the name and salary of each
employee in the EMPLOYEES table whose salary is less than that specified by a passed-in
parameter value.
PROCEDURE:
1. Create a Employee table with name, salary.
2. Create a explicit courser with parameter
3. Take dynamic input of salary
4. Filter the result salary of people less than mentioned salary
5. Then Open , Fetch and Close the courser
PL/SQL COMMANDS:
aa create table Employee_sal(emp_id number(4) primary key, emp_name varchar2(30) ,emp_sal
number(10));
--PL/SQL:
DECLARE
empDesired_sal number(10);
empName varchar2(30);
empSalary NUMBER(10);
from Employee_sal
BEGIN
empDesired_sal:= 10000;
OPEN Sal_filter(empDesired_sal);
DBMS_OUTPUT.PUT_LINE( 'Employees of salary below '|| empDesired_sal ||' are:');
LOOP
END LOOP;
CLOSE Sal_filter;
END;
OUTPUT:
4 rows selected.
Statement processed.
Employees of salary below 10000 are:
Mahesh 8999
AbhiRam 8972
AbhiRam 8972