0 Replies - 3431 Views - Last Post: 16 April 2014 - 01:42 PM

#1 bombinabirdcage  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 04-May 13

New to PL/SQL, need a pointer!

Posted 16 April 2014 - 01:42 PM

Hey all! I am taking my first PL/SQL class and I need help on what should be a simple question. I hope.

Here is the problem posed to us on our problem set:

The following code is supposed to display the lowest and highest elevations for a country name entered by
the user. However, the code does not work. Fix the code by following the guidelines for retrieving data:

DECLARE
v_country_name wf_countries.country_name%TYPE
:= ‘United States of America’;
v_lowest_elevation wf_countries.lowest_elevation%TYPE;
v_highest_elevation wf_countries.highest_elevation%TYPE;
BEGIN
SELECT lowest_elevation, highest_elevation
FROM wf_countries;
DBMS_OUTPUT.PUT_LINE('The lowest elevation in'||country_name||' is '||v_lowest_elevation
||’ and the highest elevation is '||v_highest_elevation||'.');
END;

So, I know that the problem is I need an INTO statement. I added it and when I run the code, I am getting the error "ORA-01422: exact fetch returns more than requested number of rows". I have my APEX set up to return 10,000 rows. Could someone point me to which line I am screwing up on? I haven't gotten this error before. Thank you so much in advance. Here is my code that includes the INTO statement:

DECLARE 
v_country_name wf_countries.country_name%TYPE 
:= 'United States of America'; 
v_lowest_elevation wf_countries.lowest_elevation%TYPE; 
v_highest_elevation wf_countries.highest_elevation%TYPE; 
BEGIN 
 SELECT lowest_elevation, highest_elevation 
 INTO v_lowest_elevation, v_highest_elevation
 FROM wf_countries; 
 DBMS_OUTPUT.PUT_LINE('The lowest elevation in'||v_country_name||' is '||v_lowest_elevation 
||' and the highest elevation is '||v_highest_elevation||'.'); 
END;


This post has been edited by bombinabirdcage: 16 April 2014 - 01:42 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1