3 script
3 script
declare
platform_no1 number;
begin
platform_mgmt.assign_platform(10003,'MAS1122');
platform_no1:= platform_mgmt.get_train_Assign_platform(10001,'NDLS1234');
if (platform_no1=0)
then
dbms_output.put_line( 'for train '||10001||' platform_no is not assigned for
station_code '||'NDLS1234');
else
dbms_output.put_line( 'for train '||10001||' platform_n0 '||platform_no1||' is
assigned for station_code '||'NDLS1234');
end if;
end;
/
UPDATE Station
SET Train_Arrival = TIMESTAMP '2022-01-27 08:45:00',
Train_Departure = TIMESTAMP '2022-01-27 09:15:00'
WHERE Station_Code = 'MAS1122';
DECLARE
v_message VARCHAR2(100);
BEGIN
-- Call the procedure with specific parameters
update_departure_time(12345, 'NDLS1234', TIMESTAMP '2022-01-27 01:45:00',
v_message);
-- Display the result message
DBMS_OUTPUT.PUT_LINE(v_message);
END;
/
DECLARE
v_station_cursor SYS_REFCURSOR;
v_station_code VARCHAR2(10) := 'MAS1122'; -- Replace with the desired station
code
station_code VARCHAR2(10); -- Adjust based on your actual column type
station_name VARCHAR2(50); -- Adjust based on your actual column type
train_code NUMBER(5); -- Adjust based on your actual column type
available_platform NUMBER(1); -- Adjust based on your actual column type
assign_platform NUMBER(1); -- Adjust based on your actual column type
train_name VARCHAR2(50); -- Adjust based on your actual column type
train_arrival TIMESTAMP; -- Adjust based on your actual column type
train_departure TIMESTAMP; -- Adjust based on your actual column type
BEGIN
v_station_cursor := get_station_details(v_station_code);
IF v_station_cursor%ISOPEN THEN
DBMS_OUTPUT.PUT_LINE('Station details for ' || v_station_code || ':');
LOOP
FETCH v_station_cursor INTO
station_code, station_name, train_code, available_platform,
assign_platform, train_name, train_arrival, train_departure;
EXIT WHEN v_station_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('Train ' || TO_CHAR(train_code) || ' (' || train_name ||
') arriving on Platform ' || TO_CHAR(assign_platform) ||
' at ' || TO_CHAR(train_arrival, 'YYYY-MM-DD
HH24:MI:SS') || ' and departing at ' || TO_CHAR(train_departure, 'YYYY-MM-DD
HH24:MI:SS'));
END LOOP;
CLOSE v_station_cursor;
END IF;
END;
/
DECLARE
v_result VARCHAR2(200);
BEGIN
Update_Customer_Details_Proc(
p_customer_code => 789,
p_customer_name => 'shweta',
p_customer_age => 25,
p_customer_mob => 9876543210,
p_customer_email => '[email protected]',
p_customer_gender =>'F',
p_result => v_result
);
DBMS_OUTPUT.PUT_LINE(v_result);
END;
/
BEGIN
Cancel_Booking(10000);
END;
/
-- Calculate the refund amount (e.g., 80% refund for cancellations made 48
hours before travel)
-- Replace the cancellation policy logic as per your requirements
-- This example assumes an 80% refund if cancellation is made 48 hours before
travel
-- Adjust the cancellation policy according to your business rules
-- Here, we're assuming travel_date is the date and time of the booked journey
-- You may need to adjust this logic based on your actual data and business
rules
-- For simplicity, this example uses a fixed refund policy
SELECT CASE
WHEN v_travel_date - SYSTIMESTAMP > INTERVAL '2' DAY THEN --
Assuming 48 hours before travel for the refund
v_ticket_price * 0.8 -- 80% refund
ELSE
0 -- No refund for cancellations made less than 48 hours before
travel
END INTO v_refund_amount
FROM dual; -- Use dual for single-row queries in PL/SQL
RETURN v_refund_amount;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0; -- Return 0 if PNR number not found
WHEN OTHERS THEN
RETURN 0; -- Return 0 for any other errors
END;
/
DECLARE
v_refund_amount FLOAT;
BEGIN
v_refund_amount := Calculate_Refund(10000); -- Replace with the actual PNR
number
DBMS_OUTPUT.PUT_LINE('Refund Amount: ' || v_refund_amount);
END;
/