LAb1 - 4 - BTech - Labmanual - DBS - 2022
LAb1 - 4 - BTech - Labmanual - DBS - 2022
INSTRUCTIONS TO STUDENTS
1. Students should be regular and come prepared for the lab practice.
2. In case a student misses a class, it is his/her responsibility to complete that missed
exercise(s).
3. Students should bring the observation book daily for the lab.
4. They should implement the given query/program individually.
5. Students should clearly listen to the instructions given by the faculty.
6. Once the query/program gets executed, they should show the query/program and
results to the instructors and copy the same in their observation book.
(Page 1 of 16)
7. When copying down the query in the observation book the template to be
followed is:
a. Question No
b. Question
c. Query statement
d. Output
8. When copying down the PL/SQL program in the observation book the template to
be followed is:
a. Program No
b. Program title
c. Program Code
d. Output
9. Questions for lab tests and exam need not necessarily be limited to the questions
in the manual, but could involve some variations and / or combinations of the
questions.
CONTENTS
(Page 2 of 16)
Course Outcomes (COs)
(Page 3 of 16)
Course Plan
No. Topics CO
1.0 Create the tables with the following columns and constraints with given constraint names: CO1
L1
(Page 4 of 16)
No. Topics CO
1.1 Add column REPORTS_TO to EMP table with Foreign Key constraint refereing to EMPCODE and
constraint name -FK_REPORTS_TO_EMPCODE.
1.2 Set a constraint on SKILLID column belonging to SKILL table- every column value starts with letter 'S'.
1.3 Add primary key constraint on EMPNO, SKILLID columns belonging to EMP_SKILL table having constraint
name- PK_EMPNO_SKILLID.
1.4 Set Unique constraint on PRJ_NAME belonging to PRJ_DETAILS table with constraint name
UNQ_PRJ_NAME.
(Page 5 of 16)
No. Topics CO
1.5 ADD column EMAIL to CLIENT & constraint with name 'VALID_EMAIL', valid only if-contains @. Symbols
as in email format and there must be only 3 letters after. symbol on EMAIL column.
1.6 Add Unique Key constraint on PHONE belonging to EMP having constraint name -UNQ_PHONE.
1.7 Add Unique Key constraint on EMAIL belonging to EMP having constraint name -UNQ_EMAIL.
1.8 Drop primary key constraint from MEDICAL_POLICY table and add primary key constraint on EMPNO,
POLICYNO, POLICYDATE.
1.9 Drop constraint from PREMIUM belonging to MEDICAL_POLICY table & add new constraint that
PREMIUM amount must be more than 1000/-.
(Page 6 of 16)
No. Topics CO
(Page 7 of 16)
No. Topics CO
2.8 PAY_CHECK (Leave Performance incentive, DA, PF columns blank (NULL values)
2.9 Run COMMIT command. Delete the employee having empcode 100 and confirm the result with
justification.
2.10 Update email of employee with EMPCODE 100 to rajesh@digital.com and confirm the result with
justification.
2.11 Update WORK_EXP by changing ProjId of employee 111 to P9 and confirm the result with reason.
2.12 Run COMMIT command. Delete the client information from CLIENT table having ClientID C1.
Confirm the result with reason.
2.13 Run COMMIT command. Delete a family dependent information belonging to employee with
employee id 100. Confirm the result. If records get deleted, run ROLLBACK to restore records back.
2.16 Update employee code to which 108 Reports to as 117. Confirm the result with reason. Type
COMMIT;
(Page 8 of 16)
No. Topics CO
3.3 Display name of employees who are working under employee with code 106.
3.4 Display name and email id of employees working as TECHNICAL HEAD and Designation BTECH.
3.5 Find name of employees who is drawing salary in the range 100000 to 200000. (two queries using
comparison and BETWEEN)
3.6 List the Skills owned by the employee with Employee number 101.
3.7 Display the name of skills that employee with emp code 101 is having.
3.8 Retrieve Employee code of employees who worked with clients C1 or C2 and having rating either A or
B.
3.9 Display the name of Employees who worked with client C2 and having Rating B.
3.11 Retrieve employee name, Designation and Total annual salary (Salary*12) and rename the column as
Annual_Salary. (using join)
3.12 List name of all employees and their dependents name if exist otherwise null.
3.13 List the project leader name and name of projects which have completed without time slippage and
budget slippage.
3.14 Display employee name, Salary and pay check details corresponding to month -March.
3.15 Find the Employee name and his higher authority name, phone to who the employee reports.
3.16. Display the project details in the descending order of their actual closing date.
3.17 Display Employee names, skill name in ascending order of employee number and descending order
of their skill experience.
3.18 Display Employee name, dependent name, age where the relationship is SON and sort employee
name in ascending and age in descending order.
3.19 Retrieve Employee names in Ascending order and Project names in descending order in which
employees have worked.
3.20. Find name of employees who have worked in SPYDER or APOLLO (use set Operator)
3.21 Find the name of employees who are having both skills Oracle & AZURE (use set Operator)
3.22 Retrieve the name of employees who do not work in project JUPITOR (use set Operator)
3.24 Display all employee names, email whose name starts with RA.
3.25 Retrieve the name of projects which are started between 01-01-2020 to 31-12-2020.
(Page 9 of 16)
No. Topics CO
3.26 Display the name of employees who has at least few skills that employee with employee number 101
is having.
4.1 List all employee names who are having same designation as that of employee 100.
L4
4.2 Find the name of all employees who reports to Vijay. (use set membership)
4.3 List the name, designation and email of employees who have worked in the at least one of the projects
in which Vijay has worked. (use set membership)
4.5 List the name of employees who do not work on SPYDER. (use set membership)
4.6 List the employees who have at least one skill that employees working on project P1 are possessing.
(set comparison)
4.7 List the employee names who has more work experience in project P1 compared to experience of every
employee working in project P2. (set comparison)
4.8 List the name of employees who worked in the project and client combinations in which Empcode 100
has worked. (Use set cardinality)
4.9 List the name of employees who didn’t work on any of the project in which employee with empcode
106 has worked. (Use set cardinality)
4.10 Find the name of projects for which Allocated budget is at least more than the total salary of
employees working on those projects. (correlation variable)
4.11 Display project name and the number of employees working on those projects and who obtained A or
B ratings on the project they have worked. Sort the displayed records in descending order of number of
employees worked.
4.12 Display the name of projects under which more than 2 employees are working.
4.13 Find Employee name and the number of dependents they are having.
4.15 Find employee name and having more than 20 months of total skill experience (irrespective of kind of
skill) Use WITH clause.
4.16 Create a table called EMP_PRJ containing Employee name (Emp_Name), Project Budget (Budget) and
Name of the project (Project_Name) which are led by employee with code 110.
4.17. Increment the salary of employees by 10% for the employees who are PROJECT LEADER and 5% for
employees who are DEVELOPER (use update ... case.)
4.18. Create a view EMP_SKILL_EXPERIENCE containing employee name, skill_name & skill_experience
where experience is more than 20 months.
After creating view, update the skill_ experience of any employee and confirm the result with
reasoning.
(Page 10 of 16)
No. Topics CO
4.19 Create a view EMP_DESIGNATION containing Empno, Name, Salary of employees working with role
DEVELOPER, PROJECT LEADER.
After creating view, update the salary of any employee and confirm the result with reasoning.
4.20 Display employee name and number of projects in which they are working (using scalar sub query)
Optional- Try writing 4.5 to 4.9 queries in alternate way.
5.1 Display name of all name of employees in Upper, Lower, 1st letter capital format.
L5
5.2 Display employee name and Designation of all the employees in the following format (using
concatenation operator ||)
5.3 Assume that you are displaying salary value in place with 10 space width. Display the salary so that
remaining left side spaces after displaying salary value is padded with * characters. (LAPD).
5.6 Retrieve substring part of employee email ids starting from 3rd position to 9th position characters.
5.7 Retrieve the emails of all employees by replacing digisol with digitech.
5.10 Retrieve right trimmed ClientID (RTRIM) and number of characters in the trimmed client id.
5.12 Display ASCII value of ‘A’ and Character corresponding to ascii value 65. (ASCII, CHR)
5.14 Consider any number (say 9) Retrieve square root, square and 5th power of the number.
5.16 Retrieve absolute value of -123 and remainder after dividing 123 from 10.
Floor(n)- largest integer value not greater than n and Ceil(n) - smallest integer value not less than n
5.18 Display start and end dates of projects in the format DD-Month-YYYY format. (use TO_CHAR)
5.19 Display month and Year on which projects are actually closed. (use TO_CHAR)
5.20 Display month, day, year extracted from Start_Date from Prj_Details. (use TO_CHAR)
5.21 Display the project name and the number of months between the start and end dates of the projects.
(Page 11 of 16)
No. Topics CO
Use MONTHS_BETWEEN ()
5.22 Display all the project name, end_date of the projects and the date after 2 months of end_date.
Use ADD_MONTHS ()
6.1 L
WEEK-66PL/SQL & CURSORS
Employee Number:
Employee Name:
Salary:
Project Name:
Rating:
Incentive:
Total Salary: Salary+(A-10000, B-5000, C- 3000)
Update the Other_incentive of employee in Pay_check depending on rating.
6.6 Write a PL/SQL block to calculate Jan-2021 monthly salary of employee and other components of
salary depending on Salary values in EMP table for the employee number 100. Display the salary
information of employee 100 in the following format.
Name:
Basic_Salary: Salary from EMP table
Regular Increment: Regular_Increment
Increased Basic Salary: Salary+ Regular_Increment
Performance incentive: performnce_incentive
DA: 50% of Increased Basic Salary.
PF: 12% of Increased Basic Salary.
Other Incentive: other_incentives
Advance tax paid: advance_tax
Monthly Gross Salary: Salary+Regular_Increment+ Performnce_incentive+DA+PF+
other_incentives.
Monthly Take home salary: Gross Salary – PF- advance_tax.
6.7 Do the salary processing of all employees according to the Question 6. (using cursor)
(Page 12 of 16)
No. Topics CO
6.8 Create a Table ACCOUNT (Account_Number, Balance) with constraint on Balance that Balance must be
more than 1000(minimum balance). Insert few records into the table.
Write a PL/SQL block to accept and account number, withdrawal amount from the user. Update the
Balance by deducting the withdrawal amount from the balance in the case updated balance is going to
be more than minimum balance (1000) otherwise do not update the Balance. In both cases display
proper message –
Case 1:
Current Balance: Balance
Withdrawal of <Withdrawal_amount> is Successful
Updated Current Balance: Updated balance after withdrawal
Case 2:
Current Balance: Balance
Insufficient fund to withdraw, try with lesser withdrawal amount.
6.9 Write a PL/SQL block to display- Name of the project leader, Name of the projects handled for which
budget is managed well within the Budget allocated.
6.10 Write a PL/SQL block to display the employees name and generate their email id in following format
and display the same for all employees.
Name:
Designation:
Email Generated: Name.Designation@digisoul.com
6.11 Write the PL/SQL block for Question 8. along with exception handling for-
i. Entry of not existing Account number.
ii. If Resulting balance is lesser than minimum Balance.
6.12 Assume that we have a new project Marvel and there is need for human resources with skills- 3 full
stack developer, 1 Oracle and 1 Azure each having at least 12 months of experience. Pass
skill_experience as parameter and list all the human resources available in the company satisfying the
need.
6.13 Write PL/SQL block with parameterized cursor to display all the employee code, name, designation of
the employees who are rated with a particular rating by a particular client. Pass rating and client as
parameter to the cursor. (Use cursor for loop.)
6.14 Write a PL/SQL block to display name, total work experience of 5 employees who are having highest
total work experience.
7.1 Create a Table ACCOUNT (Account_Number, Balance) with constraint on Balance that Balance must be
more than 1000(minimum balance). Insert few records into the table.
Write a stored procedure to accept and account number, withdrawal amount from the user. Update
the Balance by deducting the withdrawal amount from the balance in the case updated balance is going
to be more than minimum balance (1000) otherwise do not update the Balance. In both cases display
proper message –
Case 1:
Current Balance: Balance
(Page 13 of 16)
No. Topics CO
(Page 14 of 16)
No. Topics CO
WEEK-8 TRIGGERS
8.1 Write a trigger to be fired when basic salary hike is given to employees. Hike range and range of
basic salary for each kind of designation is as below-
References
1. Ivan Bayross, “SQL, PL/SQL-The Programming Language of ORACLE”, 4th Edition, BPB
Publications,
(Page 15 of 16)
2. Satish Asnani, “Oracle Database 11g”, PHI, 2010.
3. Scott Urman, “ORACLE – PL/SQL Programming”, Oracle Press.
(Signature of HOD)
Date: 12/03/2022
(Page 16 of 16)