Professional Documents
Culture Documents
Technical Assessment 2 GisonMark
Technical Assessment 2 GisonMark
Technical Assessment 2 GisonMark
Administration
TECHNICAL ASSESSMENT
2
M4, M5, M6, M7
Name: GISON,MARK
Section: TR31
Professor:
1. Write a procedure that displays the number of countries in a given region (prompt for value)
whose highest elevations exceed a given value (prompt for value). The procedure should accept
two formal parameters, one for a region_id and the other for an elevation value for comparison.
Use DBMS_OUTPUT.PUT_LINE to display the results in a message. Test your procedure using the
value 5 for the region_id and 2000 for the highest elevation.
1. Create a function called full_name. Pass two parameters to the function, an employee’s last name
and first name. The function should return the full name in the format, last name, comma, space,
Database System with Page 2
Administration of 4
first name (for example: Smith, Joe). (3pts)
Test your function from an anonymous block which uses a local variable to store and display the
returned value.(2pts)
2. Modify your anonymous block from the previous step to remove the local variable declaration
and call the function directly from within the DBMS_OUTPUT.PUT_LINE call. Test the block
again.(2pts)
A. Create a package specification and body called JOB_PKG, containing the following procedures:
• Create a procedure called ADD_JOB to insert a new job into the JOBS table. The procedure has
job id, job title, minimum salary and maximum salary as parameters. Ensure that the value of
maximum salary is greater than minimum salary, raise an exception if this rule is violated (create
a private procedure for salary validation). (10 pts)
A. The rows in the JOBS table store a minimum and maximum salary allowed for different JOB_ID
values. You are asked to write code to ensure that employees’ salaries fall in the range allowed for
their job type, for insert and update operations.
Database System with Page 6
Administration of 4
Create a procedure called CHECK_SALARY as follows:
▪ The subprogram accepts two parameters, one for an employee’s job ID string and the
other for the salary. (2 pts)
▪ The procedure uses the job ID to determine the minimum and maximum salary for the
specified job. (2 pts)
• If the salary parameter does not fall within the salary range of the job, inclusive of the
minimum and maximum, then it should raise an application exception, with the message
“Invalid salary <sal>. Salaries for job <jobid> must be between <min> and <max>”.
Replace the various items in the message with values supplied by parameters and
variables populated by queries. (6 pts)
Note: Submit a complete snip of the procedure. Ensure to follow the given procedure
specifications.
\
B. Create a trigger called CHECK_SALARY_TRG on the EMPLOYEES table that fires before an INSERT or
UPDATE operation on each row: (5 pts)
• The trigger must call the CHECK_SALARY procedure to carry out the business logic.
• The trigger should pass the new job ID and salary to the procedure parameters.
Note: Submit a complete snip of the trigger code. Ensure to follow the given trigger
specifications.