Week9 - Stored Functions / Assess

The questions can come in any order, so make sure you are selecting right option for all questions.

1. Create a function named 'findRoute' which have the metroTrainId as the input parameter with integer as its datatype and it should return the route name of the train.

Design Rules:
If there is route name for given metro train id then it should return the corresponding route name.

create or replace function findRoute(metroTrainId int)
return varchar is
route varchar(255);
begin
select route_name into route
from route
where id in (
  select route_id
  from metro_train
  where id = metroTrainId);
return route;
end;
/

2. Create a function named 'findTheScheduledTime' which have the metroTrainId as the input parameter with integer as its datatype and it should return the scheduled time of the train.

Design Rules:
If there is metro train id then it should return the scheduled time of that train.

create or replace function findTheScheduledTime(metroTrainId in int)
return varchar is
schedule varchar(255);
begin
select scheduled_time into schedule
from train_schedule
where metro_train_id = metroTrainId;
return schedule;
end;
/

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.