You are on page 1of 5

DEPARTMENT OF COMPUTER SCIENCE

UW
Date: 22- 05 – 21 Discipline/Semester: BSCS 6th B
Course Code: CS-320
Course: Database Application
Total Marks: 10

Sessional (35 marks)


1. How many times does the following loop execute? (2 marks)

0 times

2. Write a PL/SQL block that handles by name the following Oracle error: ORA-
1014: ORACLE shutdown in progress. The exception handler should, in turn,
raise a VALUE_ERROR exception. Hint: use the EXCEPTION INIT pragma .
(3 marks)

set serveroutput on;


declare
deadlock_detected exception;
pragma exception_init(deadlock_detected, -60);
begin
exception
when deadlock_detected then
-- errors here
end;

3. Identify the problems with (or areas for improvement in) the following loops. How
would you change the loop to improve it? (10 marks)
a.

Answer:
Replace if with changing loop condition
for i in 1 .. 76
loop
calc_totals(i);
end loop;
b.

emp_rec emp_cur%ROWTYPE;

4. Rewrite the following loop so that you do not use a loop at all. (5 marks)

There is no need of loop


give_bonus(president_id,2000000);
give_bonus(ceo_id,5000000);

5. What cursor-related statements are missing from the following block? (5 marks)

close emp_cur; is missing

close emp_cur;

end;
a.

cursor emp_cur is select * from employees where salary<100000;


no need of exit statement in loop

You might also like