Professional Documents
Culture Documents
DBS-BIT&BSE-Lab 11 PL-SQL-3
DBS-BIT&BSE-Lab 11 PL-SQL-3
DBS-BIT&BSE-Lab 11 PL-SQL-3
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
1. Create a table emp_accounts using emp table. The table has the attributes empno,
ename, job, hiredate, sal, comm at the time of table creation. Afterwards, add the
following attributs in the table: (2)
4. Create a PL/SQL function raise_sal that raises the sal of all the employees of
emp_accounts table by 10% of their exisiting sal. (3)
5. Create a database trigger sal_update that fires before the update of each row of
amp_accounts table. The trigger should display the existing sal and the updated sal
of the employee(s). (3)
6. Replace the above trigger sal_update that fires before the update of each row of
amp_accounts table. The trigger should ensure that the raise in sal should not
exceed 50% of the existing sal of the employees. In that case, the trigger should
deny the update by raising an application error.
(3)
7. Create a database trigger compute_grade that fires before the insertion of each
row of amp_accounts table. The trigger compute the grade of the newly inserted
employee on the basis of sal using the following rules:
(5)
8. Create a database trigger post_insert_loan that fires after the insertion of each
row of loan table. The trigger should set the arrears column of emp_accounts with
the loan_amount inserted. Verify the working of the trigger by inserting a row in
LOAN table.
(5)
10. Create a database trigger pre_insert_loan that fires before the insertion of each
row of loan table. The trigger will allow the insertion of a row only for the employees
with zero arrears. Furthermore, the trigger will also ensure that the loan amount can
be up to the sal of the employee. In case of failure, the trigger should raise an
application error with an error message "Loan amount is above salary" and
"Ineligible for loan due to arrears" respectively.
(10)