Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 4, 2013, 03: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, 04: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 online now   1 Reply With Quote
Old Aug 4, 2013, 04: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:46 AM.

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

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