You are on page 1of 4

Faculty of Computing & Information Technology

CC-215-L: Database Systems Lab


BS(IT&SE) Morning - Fall 2021, Semester Spring 2023
LAB – 09
Course & Lab Instructor: Dr. Asif Sohail
Objectives:
1. PL/SQL Fundamentals
2. Select statement in PL/SQL
3. PL/SQL Conditions
4. PL/SQL Loops

Allowed time: 120 mins.

Instructions:
1. Gossips are not allowed.
2. Teacher assistants are for your help, so be nice with them. Respect them as they are
teaching you. Raise your hands if you have some problem and need help from TA. Avoid
calling them by raising your voice and disturbing the environment of Lab.
3. TA may deduct your marks for any kind of ill-discipline or misconduct from your side.
4. Evaluation will be considered final and you cannot debate for the marks. So, focus on
performing the tasks when the time is given to you.
5. Paste the query as well as result table screenshot as a result of each task
Sample:
Display All the Employees from emp table
Solution:
Select * from emp

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

7369 SMITH CLERK 7902 12/17/1980 800 - 20

7499 ALLEN SALESMAN 7698 02/20/1981 1600 300 30

7521 WARD SALESMAN 7698 02/22/1981 1250 500 30

7566 JONES MANAGER 7839 04/02/1981 2975 - 20

7654 MARTIN SALESMAN 7698 09/28/1981 1250 1400 30


Task 01: [40 Marks]
1. Write a PL/SQL block that receives two numbers from the user and displays
their sum. (2)

2. Write a program that receives a string from the user. The program should
display the string on the screen, and determine whether length of the string
is even or odd? (2)

3. Write a program that retrieves ename, job, and dname of a certain employee
and outputs the message in the format "<ename> is a <job> working in
<dname>". The program should also handle the exception of
"NO_DATA_FOUND". (3)

4. Write a program that retrieves sal of a certain employee and assign it to one
out of three possible categories, "Low", "Average", or "High" on the basis of
sal amount <1000, 1000 to 1500, and above 1500 respectively. (2)

5. Write a PL/SQL block that prompts the user to input an employee’s number.
Retrieve the employee's name, job title, salary, and department name.
Display this information along with a message that shows if the employee's
salary is above or below the average salary of their department. (3)

6. The salary of an employee is to be raised by 15% annually of his/her current


salary. Write a PL/SQL program that retrieves sal of a certain employee and
projects the salary for the next five years. The output of the program should
be like:

Current Salary: 800


Salary after year 1: 920
Salary after year 2: 1058
Salary after year 3: 1216
Salary after year 4: 1399
Salary after year 5: 1609 (3)
7. Develop a PL/SQL block that displays the details of the three highest-paid
employees. (5)

8. Write a PL/SQL program that retrieves the sal and comm of an employee, if
the employee is a salesman. For other employees, the program should only
retrieve sal of the given employee. The program should raise the sal by 15%,
and comm by 10% for salesman. For other employees, the sal should be
raised by 20%. The maximum allowable raise in the net salary is 500$. If the
raise in the net salary exceeds 500$, then the net salary will be raised by
fixed 500$. The program should display all the details related to the
computations of the raise in sal. (5)

9. Develop a PL/SQL block that generates a pattern of stars (*) based on the
employee's salary. For each thousand dollars in salary, display a star. For
instance, if an employee earns $2500, display two stars. (5)

10. The company has decided to award bonus to its employees on the basis of
the grade of the employee. The employees with grade 1,2,3,4,5 will be
awarded a bonus amounting 50%,40%,30%,20%,10% of the sal
respectively. Write a PL/SQL program that receives empno of an employee,
and displays ename, grade, sal, and bonus. The program should also handle
the exception of "NO_DATA_FOUND". (5)

11. Write a PL/SQL program that displays the name of an employee in the
following format:
(4+1)

a)
S
M
I
T
H

b)
S
*M
**I
***T
****H

You might also like