Вы находитесь на странице: 1из 5

SUPINFO Academic Dept.

2ORC PL/SQL Fundamentals

Version 1.0
Use: Students/Staff
2ORC PL/SQL Fundamentals
Graded Exercise

SOMMAIRE

1 INTRODUCTION .............................................................................................. 3
2 QUESTIONS .................................................................................................... 4
2.1 4 POINTS ......................................................................................................... 4
2.2 4 POINTS ........................................................................................................ 4
2.3 3 POINTS ......................................................................................................... 4
2.4 4 POINTS ........................................................................................................ 5
2.5 3 POINTS ......................................................................................................... 5
2.6 2 POINTS ........................................................................................................ 5

Page 2 sur 5
SUPINFO International University http://www.supinfo.com
2ORC PL/SQL Fundamentals
Graded Exercise

1 INTRODUCTION
You have access to course materials (ppt+labs) for this exam, but not to internet nor any other
resource.

You must write all your answers in a single file TXT file with your scripts and comments.

This file must be named: IdBooster.txt (Ex: 123456.txt).

This work is to be done alone. Sharing and communication are prohibited.

You need the same virtual machine as during your class.

To carry out your work, you have at your disposal the olvoyage schema, which contains sample
data. Its password is oracle. It contains the following tables:

Page 3 sur 5
SUPINFO International University http://www.supinfo.com
2ORC PL/SQL Fundamentals
Graded Exercise

2 QUESTIONS

2.1 4 POINTS

Create a procedure that accepts a customer's last name as parameter and returns:
o the customer_id (buyer_id)
o the number of reservations he made (count)
o the total amount for his reservations (sum of price)
Use OUT parameters to return the data
If the last name doesn't exists, an exception shall be raised. Handle it and print a custom
message.
If the last name have more than one occurrence (ex : Cunningham), an exception shall be
raised. Handle it and print a custom message.
Test your procedure using an anonymous block and a bind variables.
Display the content of these variables after the execution.

2.2 4 POINTS

Using a trigger, enforce the following rules for employee's pass:


o The password must be at least 4 characters long
o The password must not match the first name nor the last name of the employee,
even written in a different case
This trigger have to fire at every insert or update of pass in the t_employee table.
If the password is invalid, raise a custom error and display a custom message.
Test your trigger for each case.

2.3 3 POINTS

Create a procedure which accepts a pass_id as parameter.


Using a cursor, populate an index by table of records with customer's that benefit from
this pass.
Then, parse this index by table to display only the first name, the last name and the birth
date.
Test your procedure with pass_id = 1

Page 4 sur 5
SUPINFO International University http://www.supinfo.com
2ORC PL/SQL Fundamentals
Graded Exercise

2.4 4 POINTS

Create a procedure named add_employee, which inserts a new row in the t_employee
table.
Use the seq_t_employee sequence to generate its id; the value of the remaining columns
shall be passed as parameters.
Define default values for the following columns:
o Login : use the last name followed by the first letter of the first name
o Pass : use the three last letters of the last name, followed by the three last letters
of the first name
o Salary : use the minimal salary currently stored in the t_employee table
o Comm_pct, manager_id : NULL
In order to check that your procedure works properly, execute it with only the mandatory
parameters (the last name and the first name).

2.5 3 POINTS

Write a procedure to create a new index using dynamic SQL.


Use three parameters for the index name, the table name and the column name
Here is the generic code to create an index :

CREATE INDEX index


ON table(column);

Test your procedure to create an index on the last_name column in the t_customer table

2.6 2 POINTS

Create a package with every subprograms created in previous questions.


Each program must be declared as public.

Page 5 sur 5
SUPINFO International University http://www.supinfo.com

Вам также может понравиться