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.....

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is left join and outer join same?

765


What is the difference between subquery and correlated query?

724


How to write a single statement that concatenates the words ?hello? And ?world? And assign it in a variable named greeting?

822


What is faster join or subquery?

711


Should I use mbr or gpt?

727






What are synonyms in sql?

730


What is example of database?

701


discuss about myisam key cache. : Sql dba

763


How many tables can a sql database have?

710


what happens when the column is set to auto increment and you reach the maximum value for that table? : Sql dba

765


What is a table?

728


What do you mean by dbms? What are its different types?

746


discuss about myisam index statistics collection. : Sql dba

695


How to display Row Number with Records in Oracle SQL Plus?

771


What is crud diagram?

677