Data Base Management System: Lab Assignment-6

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CH 1.

Lab assignment-6
DATA BASE MANAGEMENT SYSTEM

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


reservation details
create or replace procedure details(cust_name IN varchar) is
begin
for arow in (select flight_number,leg_number,seat_number,
customer_name,customer_phone from seat_reservation
where customer_name=cust_name) loop
dbms_output.put_line('flight number:'||arow.flight_number);
dbms_output.put_line('Leg number:'||arow.leg_number);
dbms_output.put_line('seat_number:'||arow.seat_number);
dbms_output.put_line('customer name:'||arow.customer_name);
dbms_output.put_line('customer phone:'||arow.customer_phone);
end loop;
end;
/
8. Write a procedure(with cursor) to display the company names
Along with airplane Ids.

SQL>
create or replace procedure airplane_det as
comp varchar2(10); a_id varchar2(10);
cursor cmp is select company from airplane_type;
cursor air_id is select airplane_id from airplane;
begin
open cmp;
open air_id;
dbms_output.put_line('company'||' '||'airplane id');
loop
fetch cmp into comp;
exit when cmp%notfound;
dbms_output.put_line(comp);
end loop;
close cmp;
loop
fetch air_id into a_id;
exit when air_id%notfound;
dbms_output.put_line(a_id);
end loop;
close air_id;
end;
/
Procedure created.

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


given airport code.
SQL> create function numbers_of_flights(air_code varchar2)
return number is
counts number(2) :=0;
a_code varchar2(10);
begin
select airport_code into a_code from airport;
if a_code=air_code then
select count(flight_number) into counts
from airport,flight_leg
where airport_code=arrival_airport_code
group by flight_number;
end if;
end;
/
Function created.

You might also like