Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 4, 2013, 04:05 PM   #1
bigMAC28
macrumors member
 
Join Date: Apr 2012
Location: Chicago
Why doesnt the else statement work in this?

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'
bigMAC28 is offline   0 Reply With Quote
Old Aug 4, 2013, 05:04 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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
lee1210 is offline   1 Reply With Quote
Old Aug 4, 2013, 05:44 PM   #3
bigMAC28
Thread Starter
macrumors member
 
Join Date: Apr 2012
Location: Chicago
Quote:
Originally Posted by lee1210 View Post
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
Hahaha I cant believe i missed that! Thanks!
bigMAC28 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iphoto doesnt work anymore utl768 Mac Applications and Mac App Store 0 Apr 5, 2014 03:19 PM
Tethering doesnt work borgqueenx iPhone 3 Oct 4, 2013 08:44 PM
New 5S but TouchID doesnt work twisdit iPhone 10 Sep 20, 2013 11:40 AM
Why doesnt my OTA updates ever work? Grkbella03 iOS 7 15 Aug 17, 2013 04:49 AM
'Use As Defaults' doesnt work? Sir Ruben OS X 10.8 Mountain Lion 0 Apr 21, 2013 05:21 AM

Forum Jump

All times are GMT -5. The time now is 03:57 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC