Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Passerelles numériques Vietnam

Room 205, 80B Le Duan


Da Nang VIETNAM
Tel: +84 511 262 0659
info.vietnam@passerellesnumeriques.org

MID TERM
Course name: Relational DataBase Management System
Class: …………………
A
Duration: 90 minutes

Exam ID ………………..

1. QUESTION:

Write SQL statements for following activities & print out respectively the screenshots
to show test data (the table data that you create to test each query) & query results:

a) Write a stored procedure Emp_Info (with Emp_id parameter) to print out employee’s
name, employee’s birthday, and department’s name of employee that has been out.
(2pts)
b) Write a user defined function named Emp_Salary (with Emp_id parameter) that
return the salary of the employee has been working. (2pts)
c) Write the trigger(s) to prevent (validation) the case that the end user to input invalid
employees information (level = 1 and salary >10.000.000). (2pts)
d) Write a stored procedure Emp_Update_Level (without parameter) to update
employee level to 2 if the employees that has employee level = 1 and has been
working at least three years ago (from starting date). (use UPDATE…WHERE
statement, using cursor ) (2pts)
e) Write SQL statements using cursor to update salary of all employees base on update
conditionals following(2pts):
- Update Salary = Salary + 300.000 in case (use UPDATE…WHERE statement):

1
Passerelles numériques Vietnam
Room 205, 80B Le Duan
Da Nang VIETNAM
Tel: +84 511 262 0659
info.vietnam@passerellesnumeriques.org
o Has more than 2 skills (count on emp_skill table) and
o has level of the employee = 2
- Update Salary = Salary + 500.000 in case (use UPDATE…WHERE statement):
o Has more than 2 skills (count on emp_skill table) and
o Has level of the employee = 3

Note:
- You can reuse Emp_Salary function to get employee salary.
- Use TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2) function to
determine how many emplees’s working years are.
EX : SELECT TIMESTAMPDIFF( YEAR, startDate, NOW() ) INTO @working_year FROM employees
-> working_year =6

2. INFORMATION

- Return your Exam ID only


- Draf
- Can use computer, notebook and access internet

-- The end --

You might also like