I'm dead tired and my assignment is due in seven hours. I need a kind soul(s) to help me!
So this is my first PL/SQL class. We are starting work on Procedures and Functions.
So here is the one I am stuck on. The question says:
This question uses the wf_countries table.
A. Create a procedure that accepts a country_id as a parameter and displays the name of the country and its capitol city. Name your procedure get_country_info. Save your procedure definition for later use.
B. Execute your procedure from an anonymous block, using country_id 90.
C. Re-execute the procedure from the anonymous block, this time using country_id 95. What happens?
D. Retrieve your procedure code from Saved SQL and modify it to trap the NO_DATA_FOUND exception in an exception handler. Re-execute the procedure using country_id 95 again. Now what happens?
Here is what I wrote for A:
CREATE OR REPLACE PROCEDURE get_country_info
(p_id IN wf_countries.country_id%TYPE,
p_capitol OUT wf_countries.capitol%TYPE,
p_name OUT wf_countries.country_name%TYPE)
IS
BEGIN
SELECT capitol, country_name
INTO p_capitol, p_name
FROM wf_countries
WHERE country_id=p_id;
END;
I got it to run. But then I realized that if I try to call the procedure by typing:
BEGIN
get_country_info
END;
that I need the country ID. Duh. But I can't just put get_country_info(90) because it is expecting more parameters. I only need to use the country ID as the parameter and DISPLAY the name and capitol.
I'm really frustrated and appreciate any help that you might offer.