Professional Documents
Culture Documents
Database Management Systems Lab Assesment-3 Name: P.Gopichand Reg - No: 18MIS0101 Course Code: SWE1004 Faculty: Jayaram Reddy A Slot: L1+L2
Database Management Systems Lab Assesment-3 Name: P.Gopichand Reg - No: 18MIS0101 Course Code: SWE1004 Faculty: Jayaram Reddy A Slot: L1+L2
Database Management Systems Lab Assesment-3 Name: P.Gopichand Reg - No: 18MIS0101 Course Code: SWE1004 Faculty: Jayaram Reddy A Slot: L1+L2
Lab Assesment-3
Name : P.Gopichand
Reg.No: 18MIS0101
Course code : SWE1004
Faculty: Jayaram reddy A
Slot: L1+L2
16 else 24 e
n
17 if num2>num3 then d
;
18 max1:=num2;
2
19 else
5
20 max1:=num3;
/
21 end if;
Enter value for num1: 1000
old 7: num1:=&num1;
new 7: num1:=1000;
Enter value for num2: 1500
old 8: num2:=&num2;
new 8: num2:=1500;
Enter value for num3: 3000
old 9: num3:=&num3;
new 9: num3:=3000;
The largest number is:3000
2 f1 number; old 8:
3 f2 number; dbms_output.pu
12 dbms_output.put_line(c); f1:=f2; 0
13 f2:=c; 1
14 end loop; 1
15 end; 2
16 / 3
5
PL/SQL procedure successfully completed.
4. Write a block to raise an exception if the reservation date is less than today's date.
S
Q
SQL> declare L
2 reservation_date date; >
3 today_date date;
4 date_invalid exception; d
5 n number; e
6 begin c
7 reservation_date:=to_date('&reservation_date','dd/mm/yyyy'); l
8 today_date:=sysdate; a
9 n:=reservation_date-today_date; r
10 IF n>0 THEN e
11 RAISE date_invalid; 2 cursor
12 END IF; details_of_f
lights is
13 EXCEPTION select *
from flight;
14 WHEN date_invalid THEN
3 flight
15 dbms_output.put_line('Reservation date is not valid'); details_of_f
16 end; lights
%rowtype;
17 /
Enter value for reservation_date: 12/8/2016
old 7: reservation_date:=to_date('&reservation_date','dd/mm/yyyy');
new 7: reservation_date:=to_date('12/8/2016','dd/mm/yyyy');
SQL> declare
2 cursor f1 is select * from flight
3 where flight_number in(select flight_number from fare where amount between 1200
and 2900);
4 f f1%rowtype;
5 begin
6 open f1;
7 loop
8 fetch f1 into f;
9 exit when f1%notfound;
10 dbms_output.put_line(f.flight_number||' '||f.airline);
11 end loop;
17mis0051
kingfisher
12 close f1;
13 end; PL/SQL
procedure
14 / successfully
completed.
7. Write a procedure to accept the customer name and display the reservation details.
9. Write a function to give the number of flights arriving for a given airport code.
Function created.
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.
Trigger created.
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.)
14. Write a trigger to update the myflight table when flight tuple is inserted.
Type created.
Table created.
Package created.
Package body
created.
6 FROM seats WHERE name=cus;
7 dbms_output.put_line('rcptno: '|| c_sal);
8 END find_rcp; S
9 END passe_rcp; Q
10 / L
> create or replace package p1 as 2
procedure listseats;
3 end p1;
4/
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY p1 AS
2 PROCEDURE listseats IS
3 CURSOR c_customers is SELECT name FROM seats;
4 TYPE c_list is TABLE OF varchar;
5 name_list c_list:= c_list();
6 counter integer:=0;
7 BEGIN
8 FOR n IN c_customers
9 LOOP
10 counter := counter +1;
11 name_list.extend;
12 name_list(counter) := n.name;
13 dbms_output.put_line('Customer(' ||counter|| ')'||name_list(counter));
14 END LOOP;
15 END listseats;
16
17 END p1;
18 /
SQL> begin
2 p1.listseats;
3 end;
4/