0% found this document useful (0 votes)
130 views

Lab Assesment-5: Cycle Sheet-3

This document contains a lab assessment with 15 questions related to PL/SQL programming. It asks the student to write PL/SQL code like blocks, procedures, functions, triggers and cursors to perform tasks like generating a Fibonacci series, finding the greatest of three numbers, validating reservation dates, retrieving flight details within a range, and working with nested tables and packages. The student is asked to write code that handles exceptions, updates related tables, and accepts parameters to display specific reservation details.

Uploaded by

pavan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

Lab Assesment-5: Cycle Sheet-3

This document contains a lab assessment with 15 questions related to PL/SQL programming. It asks the student to write PL/SQL code like blocks, procedures, functions, triggers and cursors to perform tasks like generating a Fibonacci series, finding the greatest of three numbers, validating reservation dates, retrieving flight details within a range, and working with nested tables and packages. The student is asked to write code that handles exceptions, updates related tables, and accepts parameters to display specific reservation details.

Uploaded by

pavan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CYCLE SHEET-3

LAB ASSESMENT-5

NAME:-VENKALA GURU TEJASWINI


REG.NO:-18MIS0291
FACULTY:-KARTHIKEYAN.J
1. Write a PL/SQL block to display the reverse of numbers between
1 and 100.
Ans:-
SQL>setserveroutputon;
SQL> begin
for;
;.
SQL> declare 2
i number;
begin
for i in reverse 1..100 loop
dbms_output.put_line(i);
end loop;

99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
PL/SQL procedure successfully completed.

2. Write a PL/SQL block to find the greatest of three numbers.


SQL> declare
num1 number;
num2 number;
num3 number;
max1 number;
begin
num1:=&num1;
num2:=&num2;
num3:=&num3;
if num1>num2 then
if num1>num3 then
max1:=num1;
else
max1:=num3;
end if;
else
if num2>num3 then
max1:=num2;
else
max1:=num3;
end if;
end if;
dbms_output.put_line('The largest number
is:'||max1); end;
25 /

Enter value for num1: 19


old 7: num1:=&num1;
new 7: num1:=12; Enter
value for num2: 23 old
8: num2:=&num2;
new 8: num2:=23; Enter
value for num3: 34 old
9: num3:=&num3;
new 9: num3:=34;
The largest number is:34

PL/SQL procedure successfully completed.

3. Write a PL/SQL block to generate Fibonacci series.


SQL> declare
g1 number;
g2 number;
i number;
c number;
n number;
begin
g1:=0;
g2:=1;
dbms_output.put_line('Enter the value of
n:'); n:=&n;
dbms_output.put_line(g1);
dbms_output.put_line(g2);
for i in 1..n loop c:=g1+g2;
dbms_output.put_line(c);
g1:=g2;
g2:=c;
end loop;
end;
/
Enter value for n: 23
old 11: n:=&n;
new 11: n:=23; Enter
the value of n: 0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
PL/SQL procedure successfully completed.

4. Write a block to raise an exception if the reservation date is less


than today's date.
5. Write a cursor to give the details of all the flights.
6. Write a cursor to give flight details that range between 1200 and
2900.

7. Write a procedure to accept the customer name and display the


reservation details.
8. Write a procedure(with cursor) to display the company names
along with airplane ids.

9. Write a function to give the number of flights arriving for a given


airport code.
10. Write a function to return the airport name which is having
highest number of airplane types landing.

11. Write a trigger to update the airplane type in airplane when


parent table is updated.
12. Write a trigger to delete all the foreign key references when the
parent primary key is deleted. (If you have added cascade while
create table ignore this question.)

13. Write a trigger to raise an exception if reservation date is invalid


while insertion. (should be latter than current date.)
14. Write a trigger to update the myflight table when flight tuple is
inserted.

15. Create a nested table from the airplane database. Create a


package with two functions on the table.
*** THE END ***

You might also like