You are on page 1of 2

CS 262: DBMS Lab

Cycle – 3

1. Write a PL/SQL program to print the first n perfect numbers.


2. Consider the following table. If quantity of an item is less than its
ROL(Reorder Level), then the item should be reordered. Write a PL/Sql
block that notifies the number of items to be reordered in the Inventory
table.

INVENTORY
Item_ID Item_name Quantity ROL ROQ
3. Write a PL/SQL program to read two numbers, calculate their HCF and
LCM and store the details in the numbers table.

NUMBERS
Number1 Number2 HCF LCM
4. Consider the following relation schemas
Inventory
Product_ID Product_name Quantity

Purchase_Record
Product_ID Status Date
Write a PL/SQL block to read the quantity of a product from inventory and if it is
> 0 reduce the quantity by 1 and record the status of purchase of that product
as ‘PURCHASED’. Otherwise record the status of purchase of that product as
‘OUT OF STOCK’. While recording the status of a purchase, record the date of
transaction.

5. Write a PL/SQL block to handle the following built-in exceptions


 no_data_found
 too_many_rows
 zero_divide
6. Write a PL/SQL block to validate the birth date of an employee in the
following emp table. If the date of birth of any employee is found to be
invalid, using an exception display relevant message and update it with
new birth date.
Emp
Eno Name Birthdate
Hint: If calculated age of employee is less than 22 or greater than 60 then birthdate is
invalid.
7. Consider the following relation schemas
Course
Courseid name Offering_deptno

Enrollment
Student_Id Courseid Instructor_name

Del_Audit
CourseId Rows_deleted date
Write a PL/SQL block to delete records of all courses for which no student
is enrolled and then record the Course ID, no of rows deleted and date on
which deletion occurred in the Del_Audit table.

8. Write a PL/SQL block that displays the employee names and their total earnings
from the Emp Table.
Hint: Total earning of an employee = 12*(gross_salary+commission)

9. Consider the following customer table:

Cust_ID Name BirthDate Sex AnnualIncome Rating


C111 Alex 20-Aug-98 Male Above 100K 3
C112 Wayne 15-Nov-85 Male 70k-80k 2
C234 Tom 03-Jan-79 Male 80k-90k 1

Update the Rating of customers based on the following criteria:

 If Annual_Income > 100k then rating = 1


 Annual_Income is 50k – 100k then rating = 2 and
 Annual Income < 50k then rating =3.
Show the status of updation in the console. If no records are updated, Display
the message “NO RECORDS ARE UPDATED”. Otherwise Display the count of
records updated.

You might also like