Create a function in PL/SQL that will use the column euro_amnt from the euro_data table.
The function will do this:
· Take the euro symbol from the currency.
· Change the comma in the data to a period, to make it more like US dollars.
· Convert the euros to American dollar amounts. Use 1 euro = 1.05 dollars. Create a variable named
v_rate to store the 1.05 exchange value.
So the return value is the amount of money that the euros are worth in American dollars. Do not have
the function show the money amount in dollars, just return it as a number.
This function can be created quickly using the system functions REPLACE, SUBSTR, etc. nested inside of
each other. - ANS_CREATE OR REPLACE FUNCTION convert_to_usd(amount IN NUMBER)
RETURN NUMBER
IS
v_rate NUMBER := 1.05;
v_usd_amount NUMBER := 0;
BEGIN
v_usd_amount := REPLACE(amount, ',', '.');
v_usd_amount := v_usd_amount * v_rate;
The function will do this:
· Take the euro symbol from the currency.
· Change the comma in the data to a period, to make it more like US dollars.
· Convert the euros to American dollar amounts. Use 1 euro = 1.05 dollars. Create a variable named
v_rate to store the 1.05 exchange value.
So the return value is the amount of money that the euros are worth in American dollars. Do not have
the function show the money amount in dollars, just return it as a number.
This function can be created quickly using the system functions REPLACE, SUBSTR, etc. nested inside of
each other. - ANS_CREATE OR REPLACE FUNCTION convert_to_usd(amount IN NUMBER)
RETURN NUMBER
IS
v_rate NUMBER := 1.05;
v_usd_amount NUMBER := 0;
BEGIN
v_usd_amount := REPLACE(amount, ',', '.');
v_usd_amount := v_usd_amount * v_rate;