Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bigMAC28

macrumors member
Original poster
Apr 16, 2012
91
0
Chicago
Code:
ACCEPT p_1 PROMPT 'Please enter an Interger between 1 and 100:'

DECLARE
  v_rank number;
	v_input	Popular_names.rank%TYPE := '&p_1';
  v_mname varchar2(20);
  v_fname varchar2(20);	
BEGIN
  SELECT rank
  INTO v_rank
  FROM Popular_names
	WHERE rank=v_input;
  IF v_input>= 1 and v_input<= 100 THEN
      DBMS_OUTPUT.PUT_LINE('Valid!');
  ELSE
    DBMS_OUTPUT.PUT_LINE('Invalid Number!');
END IF;
END;


The IF Statement works fine but i get a 01403. 00000 - "no data found" error when i enter '101'
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Your conditional is after you do a select with an invalid value. Put your select inside the if or catch the error and handle it instead.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.