Sie sind auf Seite 1von 6

S TUDENT STUDENT

FULL NAME: NUMBER:

SUBJECT: DOS311C TEST DATE: DURATION:


DEVELOPMENT SOFTWARE III 9 May 2008 2 hours

FACULTY OF INFORMATICS & DESIGN


COURSE:
National Diploma in Information Technology

SUBJECT COORDINATOR:
Ms. G. Khan (Examiner) Question Student Mark Max. Score

1 4
SUBJECT COORDINATOR:
Ms. E. Zietsman (Examiner) 2 11
LECTURERS: 3 15
Part Time 4 15
Mr. M Marte
5 13
MODERATORS:
6 12
Mr. M. Marte (Internal)
7 --
SPECIAL INSTRUCTIONS: 8 --
Answer all questions.
You may code in pencil. 9 --

REQUIREMENTS: 10 --
An Answer Book is required.
70

%
Development Software III Module A – Procedures, Packages & Functions

Specification
The Elite 500 Club is a very exclusive club that only allows 500 members to the club (you
can become a member by invitation only – and by paying an extravagant entrance and
membership fee). The following tables keep track of the reservations of the dining room
and the orders of the members while dining.

TABLE FIELD TYPE

MEMBER MEM_NR NUMBER(3) (PK)


MEM_NAME VARCHAR2(25)
MEM_INITIALS VARCHAR2(4)
MEM_SURNAME VARCHAR2(25)
MEM_EMAIL VARCHAR2(25)
MEM_CELL VARCHAR2(13)
MEM_PHONE_NR VARCHAR2(13)
MEM_TYPE VARCHAR2(6)
MEM_ENTRY_DATE DATE
MEM_RESIGN_DATE DATE

TABLE TABLE_NR NUMBER(2) (PK)


NO_SEATS NUMBER(2)

RESERVATION RES_NR NUMBER(11) (PK)


RES_MEM_NR NUMBER(3) (FK)
RES_TABLE_ID NUMBER(2) (FK)
RES_DATE DATE
RES_NR_PEOPLE NUMBER(2)

The appendix contains the SQL code used to create the tables. Sample data are also
included.

EXPLANATION OF THE PROCESS:

Only one booking per table is made for a specific day and a member (with guests) may
only book for dinner once a month.

REQUIRED
You are required to create the procedures, functions and packages using
ORACLE PL/SQL statements. Where appropriate use your already defined
procedures and functions in your answers.

QUESTION 1 (4 MARKS)

Create a package specification name ELITE_PACKAGE that includes all public


procedures and functions described in questions 2 to 6.

Test #1 – April 2008 Page 2 of 6 pages


Development Software III Module A – Procedures, Packages & Functions

Create the package ELITE_BODY consisting of all the procedures and functions
in the following questions.

QUESTION 2 (11 MARKS)

Write a function CHECK_MONTH that checks whether a member has made any
reservation for the current month. It receives the member identification and
reservation date. The function returns true if a member has already made a
reservation for this month otherwise false.

HINT: Use the TO_CAHR and the format MONYY to evaluate the dates.

QUESTION 3 (15 MARKS)

Write a private function CHECK_RESERVATION to determine the availability of a


table for a specific day. The function receives the DATE of the required
reservation and the number of people the reservation is for. The function
returns the available table number. If there are no tables available it returns a
zero. (The restaurant do not allow for tables to be shifted together to allow for
bigger parties.)

QUESTION 4 (15 MARKS)

Write a public procedure RESERVE_TABLE. It receives the DATE of the


reservation, number of people and the member identification.

Define and raise an exception TABLE_EXCEPTION if a table is not available or


the member has already reserved a table for the month. Display an
appropriate error message.

If the member identification received is invalid an integrity error (ORA-02291)


will occur. Use the PRAGMA EXCEPTION_INIT, link it to a user-defined exception
named MEMBER_EXCEPTION and display an appropriate error message.

If a table is available, reserve the table by inserting a row in the


C_RESERVATION table. Display an appropriate message when a reservation
was made. Use the already defined sequence TABLE_RES_SEQ for the RES_NR.

QUESTION 5 (13 MARKS)

Write a procedure named RESERVATIONS that print all the reservations for a
specific evening. It receives that date as a parameter. The format of the
report is as follows:

Test #1 – April 2008 Page 3 of 6 pages


Development Software III Module A – Procedures, Packages & Functions

Reservation for DD-MONTH-YY


TABLE_NR NO_SEATS MEM_NAME RES_NR_PEOPLE empty seats
TABLE_NR NO_SEATS MEM_NAME RES_NR_PEOPLE empty seats
TABLE_NR NO_SEATS MEM_NAME RES_NR_PEOPLE empty seats
Total empty seats xxxxxxxxxxx

QUESTION 6 (12 MARKS)

Write a procedure MEMBER_RESERVATIONS which lists all the reservations per


member in the following format is:-

Reservations report
MEM_NR MEM_INITIALS MEM_SURNAME
RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE
RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE
RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE

MEM_NR MEM_INITIALS MEM_SURNAME


RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE
RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE
RES_NR RES_TABLE_ID RES_DATE RES_NR_PEOPLE

The report sequence is in ascending member number and descending


reservation date.

Test #1 – April 2008 Page 4 of 6 pages


Development Software III Module A – Procedures, Packages & Functions

Appendix
DROP TABLE member;
DROP TABLE tablex;
DROP TABLE reservation;

CREATE TABLE member (


mem_nr
NUMBER(3),
mem_name VARCHAR2(25),
mem_initials VARCHAR2(4),
mem_surname VARCHAR2(25),
mem_email VARCHAR2(25),
mem_cell VARCHAR2(13),
mem_phone_nr VARCHAR2(13),
mem_type VARCHAR2(6),
mem_entry_date DATE,
mem_resign_date DATE,
CONSTRAINT member_pk PRIMARY KEY (mem_nr)
);

CREATE TABLE tablex (


table_nr NUMBER(2),
no_seats NUMBER(2),
CONSTRAINT tablex_nr_pk PRIMARY KEY (table_nr)
);

CREATE TABLE reservation (


res_nr
NUMBER(11),
res_mem_nr NUMBER(3),
res_table_id NUMBER(2),
res_date DATE,
res_nr_people NUMBER(2),
CONSTRAINT c_res_nr_pk PRIMARY KEY (res_nr),
CONSTRAINT member_res_fk FOREIGN KEY (res_mem_nr) REFERENCES member
);

INSERT INTO member


VALUES (12, 'LEONARDO', 'LC', 'DA VINCI','davinci@vatican.org', 0821234689,
'021-4581446', 'GOLD', '01-JAN-1955', NULL);
INSERT INTO member
VALUES (79, 'BABE', 'BT', 'THE PIG','pigb@hotmail.com', 0843461331, '021-
9102132', 'BLUE', '01-DEC-1989', NULL);
INSERT INTO member
VALUES (83, 'MONICA', 'MC', 'LEWINSKY','lewinskym@hotmail.com', 0820070071,
'021-9306124', 'SILVER', '01-JAN-1961', NULL);
INSERT INTO member
VALUES (111, 'VLADIMAR', 'VLAD', 'VLADOVSKI','vlad@hotmail.com', 0836543124,
'021-8548146', 'GOLD', '01-JAN-1956', NULL);
INSERT INTO member
VALUES (142, 'MISTER', 'MR', 'PRICE','mrprice@hotmail.com', 0840769169, '021-
9397212', 'SILVER', '01-JAN-1966', NULL);
INSERT INTO member
VALUES (323, 'ZZ', 'ZZ', 'TOP','zztop@hotmail.com', 0837733915, '021-5588996',
'BLUE', '01-JAN-1977', NULL);
INSERT INTO member

Test #1 – April 2008 Page 5 of 6 pages


Development Software III Module A – Procedures, Packages & Functions

VALUES (376, 'WILLIAM', 'WC', 'GATES','billgates@microsoft.org', 0842911372,


'021-4603586', 'SILVER', '01-APR-1969', NULL);
INSERT INTO member
VALUES (401, 'SAMUEL', 'SE', 'EETO','sameto@barcelona.club', 0831122334, '021-
9012332', 'BLUE', '01-JAN-1992', NULL);
INSERT INTO member
VALUES (465, 'HENRY', 'HT', 'THIERY','thieryh@arsenal.club', 0831792123, '021-
9304455', 'BLUE', '01-JAN-1995', NULL);
INSERT INTO member
VALUES (499, 'MUHAMED', 'MA', 'ALI','stinglikeabee@hotmail.com', 0823123689,
'021-6263231', 'BLUE', '01-JAN-1970', NULL);

INSERT INTO tablex VALUES (1, 2);


INSERT INTO tablex VALUES (2, 2);
INSERT INTO tablex VALUES (3, 2);
INSERT INTO tablex VALUES (4, 2);
INSERT INTO tablex VALUES (5, 4);
INSERT INTO tablex VALUES (6, 4);
INSERT INTO tablex VALUES (7, 4);

INSERT INTO reservation VALUES (1002, 12, 1, '12-MAR-2006', 1);


INSERT INTO reservation VALUES (1003, 79, 7, '12-MAR-2006', 4);
INSERT INTO reservation VALUES (1004, 83, 5, '12-MAR-2006', 3);
INSERT INTO reservation VALUES (1007, 376, 2,'12-MAR-2006', 2);
INSERT INTO reservation VALUES (1009, 401, 3,'12-MAR-2006', 2);
INSERT INTO reservation VALUES (1012, 465, 6,'12-MAR-2006', 4);
INSERT INTO reservation VALUES (1017, 499, 4,'12-MAR-2006', 2);
INSERT INTO reservation VALUES (1019, 111, 4,'17-MAR-2006', 2);
INSERT INTO reservation VALUES (1020, 142, 6,'01-APR-2006', 4);
INSERT INTO reservation VALUES (1033, 323, 5,'21-APR-2006', 2);
INSERT INTO reservation VALUES (1077, 12, 1, '23-APR-2006', 2);
INSERT INTO reservation VALUES (1081, 79, 7, '23-APR-2006', 4);
INSERT INTO reservation VALUES (1089, 83, 5, '24-APR-2006', 3);
INSERT INTO reservation VALUES (1090, 376, 2,'24-APR-2006', 2);
INSERT INTO reservation VALUES (1099, 401, 3,'27-APR-2006', 2);
INSERT INTO reservation VALUES (1100, 83, 5, '24-MAY-2006', 3);
INSERT INTO reservation VALUES (1110, 376, 2,'22-MAY-2006', 2);
INSERT INTO reservation VALUES (1111, 401, 3,'23-MAY-2006', 2);
INSERT INTO reservation VALUES (1113, 465, 6, '01-MAY-2006', 4);
INSERT INTO reservation VALUES (1117, 499, 4,'25-MAY-2006', 2);
INSERT INTO reservation VALUES (1119, 111, 1,'26-MAY-2006', 2);
INSERT INTO reservation VALUES (1120, 142, 6,'26-MAY-2006', 3);
INSERT INTO reservation VALUES (1121, 323, 2,'26-MAY-2006', 2);

create sequence table_res_seq


start with 1201;

commit;

END OF TEST PAPER

Test #1 – April 2008 Page 6 of 6 pages

Das könnte Ihnen auch gefallen