Aim:
To print the passenger table with procedure using PL/SQL queries.Algorithm:
Step 1: Start the program.Step 2: Create the table using SQL queries.
Step 3: Put the condition to print the passenger details with PL/SQL.
Step 4: Get the output.
Step 5: Stop the process.
PROGRAM
create table passenger(Ticket_no varchar(10),Name varchar(25),age number(3),Gender varchar(10),Start_place varchar(20),Destination varchar(20),fare number(8,2),primary key(Ticket_no));
insert into passenger values ('M1001','Naveen',20,'male','coimbatore','dharmapuri',450);
insert into passenger values ('M1002','praveen',20,'male','Hosur','palacode',450);
insert into passenger values ('M1003','varun',30,'male','Krishnagri','Thambaram',450);
insert into passenger values ('M1004','keerthi',40,'male','Chennai','dharmapuri',450);
insert into passenger values ('M1005','kumar',25,'male','Madurai','Kanyakumari',450);
select * from passenger;
PL/SQL PROGRAM
begin
dbms_output.put_line('passenger in database');
for t in (select Ticket_no,Name,age,Gender,Start_place,Destination,fare from passenger)
loop
dbms_output.put_line(t.Ticket_no);
dbms_output.put_line(t.Name);
dbms_output.put_line(t.age);
dbms_output.put_line(t.Gender);
dbms_output.put_line(t.Start_place);
dbms_output.put_line(t.Destination);
dbms_output.put_line(t.fare);
end loop;
end;
OUTPUT:
passenger in database
M1002
praveen
20
male
Hosur
palacode
450
M1003
varun
30
male
Krishnagri
Thambaram
450
M1004
keerthi
40
male
Chennai
dharmapuri
450
M1005
kumar
25
male
Madurai
Kanyakumari
450
M1001
Naveen
20
male
coimbatore
dharmapuri
450
إرسال تعليق