Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested IF Script

Status
Not open for further replies.

acct98

IS-IT--Management
Aug 15, 2002
194
US
Does anyone have a nested if script that they can provide as an example? Im trying to do nested if one column.

 
Acct,

Here is a contrived example of nested IFs (and ELSIFs), which I saved to, and executed from, a script named TT_63:
Code:
set serveroutput on
accept x prompt "Enter some numeric value: "
declare
	procedure p (str in varchar2) is
	begin
		dbms_output.put_line (str);
	end;
begin
	if &x > 10 then
		p('&X is greater than 10.');
		if &x > 25 then
			p('&x is also greater than 25');
		elsif &X > 18 then
			p('&x is also greater than 18');
		else
			p('&x is between 11 and 18');
		end if;
	elsif	&X = 10 then
		p('&x = 10.');
	else
		p('&x is less than 10.');
		if &x < 5 then
			p('&x is also less than 5.');
		else
			p('&x is between 5 and 9.');
		end if;
	end if;
end;
/

SQL> @tt_63
Enter some numeric value: 30
30 is greater than 10.
30 is also greater than 25
SQL> @tt_63
Enter some numeric value: 3
3 is less than 10.
3 is also less than 5.
SQL>

Is this the type of example you wanted?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 01:06 (04Feb04) GMT, 18:06 (03Feb04) Mountain Time)
 
Thanks -- This is just what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top