Aim:
             To find the Table Fare Calculation using PL/SQL.

Algorithm:

Step 1: Start the program.

Step 2: Create the table using SQL queries.

Step 3: Insert the records.

Step 4: Declare the variable n.

Step 5: Execute the for loop for calculation.

Step 6: Get the output.

Step 7: Stop the process.

Program

create table booking2(bus_code varchar(10),origin varchar(20),fare decimal(8,2),destination varchar(20),time_of_departure varchar(10),date_of_travelling date);

insert into booking2 values('BS10023','coimbatore',450,'chennai','5.00AM','29-JUN-04');
insert into booking2 values('BS10024','chennai',350,'palacode','4.00AM','29-OCT-04');
insert into booking2 values('BS10025','Hosur',550,'palacode','5.00PM','29-JULY-04');
insert into booking2 values('BS10026','Dharmapuri',250,'LMW','3.00AM','19-JUN-04');
insert into booking2 values('BS10027','chennai',450,'palacode','7.00PM','09-JUN-04');

DECLARE
 n varchar(10);
BEGIN
n:=:n;
for t in (select fare from booking2 where n=bus_code)
loop
dbms_output.put_line('The bus_code is'||n);
dbms_output.put_line('The passenger  fare  is :'||t. fare);
end loop;
END;

OUTPUT:

BS10027
  :N

The bus_code is: BS10027
The passenger fare is : 450

Post a Comment

Previous Post Next Post