You are on page 1of 1

PL/SQL Exam Part 2 (10 pts each)

1. Follow the instructions below:


a. Create a table named TRNG_initials. It should have the columns employee code, job code and
annual salary as well as the data from employees table. When you issue the command DESC
TRNG_initials, the table structure should look like the structure below.

Name Null? Type


------------------------------- -------- ----
ID NUMBER(4)
WORK VARCHAR2(10)
ANN_SAL NUMBER

b. Create a procedure named INSERT_AGAIN_initials that deletes all the records from the table you
created previously. After deleting all the records, it should also re-insert the data that was previously
deleted. Use a FOR LOOP or other iterative controls in re-inserting the records.

2. Follow the instructions below:


a. Add a column named TO_DATE having a date datatype to the table you created in number 1.

b. Create a PL/SQL block that updates the TO_DATE column. The value of this column is the hiredate of
employees plus 1 year. Use cursors and FOR LOOP or other iterative controls.

3. Create a function named CONVERT_initials that converts a number from 1 to 9999 to words. It should have
one parameter which accepts the number to be converted.

How to check your work: SELECT CONVERT_initials(1500)


FROM dual;
Result: ONE THOUSAND FIVE HUNDRED

4. Create a procedure named FACTORS_initials. This procedure must display the factors of the numbers 1 to
15.

HINT: Use two FOR LOOPS or other iterative controls, MOD function and IF statement.

The result should look like this:

Factors of 6:
1 AND 6
2 AND 3
3 AND 2
6 AND 1

5. Create a procedure named TOO_MANY_ROW_initials that uses an implicit cursor to select the employee
ID, date hired, salary, and employee last name from the EMPLOYEES table. Write an exception to handle
the case of too many rows (TOO_MANY_ROWS), displaying a nice text message.

6. Add a where clause to your query, specifying that employee ID must be equal to 669900. Add an exception
to handle the case of no rows found (NO_DATA_FOUND), again putting out a message.
Name the procedure as NO_DATA_FOUND_initials

7. Create a package name PCKG_initials. The package should contain the procedure you created in number
1.b and the function you created in number 3. Remember that packages have a package specification and
a package body.

You might also like