I m giving Source, Destination and Age. Write a procedure or
function, it will give to u this source to destination
tickets are available or not, if available then check this
person is senior citizen or not,if this person is senior
citizen then give some discount.
PLZ give this answer......
Thanks advance.....

Answers were Sorted based on User's Feedback



I m giving Source, Destination and Age. Write a procedure or function, it will give to u this sour..

Answer / aritra

TRY THIS ONE ...

CREATE TABLE FARE_DETAILS
( SOURCE VARCHAR2(100),
DESTINATION VARCHAR2(100),
FARES NUMBER(10,2));


create or replace procedure PROC_TCKT_RESERVATION
(m_source IN VARCHAR2,
m_destination IN VARCHAR2,
m_age IN NUMBER
)
is
v_source FARE_DETAILS.SOURCE%TYPE;
v_destination FARE_DETAILS.DESTINATION%TYPE;
v_fares FARE_DETAILS.FARES%TYPE;
v_fares_out FARE_DETAILS.FARES%TYPE;
begin
IF m_source= m_destination THEN
RAISE_APPLICATION_ERROR(-20001,'SOURCE, DESTINATION
SHOULD NOT BE SAME');
END IF;
SELECT FARES
INTO v_fares
FROM FARE_DETAILS
WHERE SOURCE= m_source
AND DESTINATION= m_destination ;
IF m_age>=60 THEN
v_fares_out:= (v_fares-v_fares*0.3);
DBMS_OUTPUT.PUT_LINE('GIVEN AGE IS FOR SENIOR CITIZEN,
FARE IS '||v_fares_out);
ELSE
v_fares_out:= v_fares;
DBMS_OUTPUT.PUT_LINE(' FARE IS '||v_fares_out);
END IF;

EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20001,'NO DATA FOUND ..ENTER
COREECT SOURCE/DESTINATION');

end PROC_TCKT_RESERVATION;

Is This Answer Correct ?    13 Yes 1 No

I m giving Source, Destination and Age. Write a procedure or function, it will give to u this sour..

Answer / kavitha nedigunta

CREATE TABLE FARE_DETAILS
( SOURCE VARCHAR2(100),
DESTINATION VARCHAR2(100),
FARES NUMBER(10,2));


CREATE OR REPLACE FUNCTION TCKT_RESERVATION_FUN
(
I_SOURCE IN FARE_DETAILS.SOURCE%TYPE,
I_DESTINATION IN FARE_DETAILS.DESTINATION%TYPE,
I_AGE IN FARE_DETAILS.FARES%TYPE
) RETURN VARCHAR2
AS
L_OUT_PUT VARCHAR2(2000) DEFAULT NULL;
L_FARES FARE_DETAILS.FARES%TYPE;
BEGIN

IF UPPER(TRIM(I_SOURCE)) = UPPER(TRIM(I_DESTINATION)) THEN
l_OUT_PUT := 'SOURCE, DESTINATION SHOULD NOT BE SAME';
RETURN l_OUT_PUT;
END IF;

SELECT FARES INTO L_FARES FROM FARE_DETAILS
WHERE UPPER(TRIM(SOURCE)) = UPPER(TRIM(I_SOURCE))
AND UPPER(TRIM(DESTINATION)) = UPPER(TRIM
(I_DESTINATION));

IF I_AGE >=60 THEN
l_OUT_PUT:= (L_FARES-L_FARES*0.3);
ELSE
l_OUT_PUT := L_FARES;
END IF;
RETURN l_OUT_PUT;
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_OUT_PUT :='NO DATA FOUND ..ENTER COREECT
SOURCE/DESTINATION';
RETURN l_OUT_PUT;
END TCKT_RESERVATION_FUN;

Is This Answer Correct ?    5 Yes 1 No

I m giving Source, Destination and Age. Write a procedure or function, it will give to u this sour..

Answer / ajitnayak

Hi Aritra, Kavitha,
Ur logic is correct, but it's not complete all point, where ur program is identify tickets are available or not then u program should calculate fare and all details.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What port does sql server use?

0 Answers  


how can we take a backup of a mysql table and how can we restore it. ? : Sql dba

0 Answers  


what is the difernece between named and anonymous pl/sql blocks??

8 Answers   TCS, Wells Fargo,


what is column? : Sql dba

0 Answers  


What is a primary key sql?

0 Answers  






How would you convert date into julian date format?

0 Answers  


What are different types of sql commands?

0 Answers  


what is acid property in database? : Sql dba

0 Answers  


Why do we need a foreign key?

0 Answers  


i want run a sql query query? which phases are run in a back ground? pls tell me the answer

1 Answers  


how is myisam table stored? : Sql dba

0 Answers  


..........refers to the disk mirroring

2 Answers   iFlex,


Categories