Re: if else logic in SQLPlus scripts
From: Odd Morten Sveås <odd.morten.sveas_at_accenture.com>
Date: 28 Sep 2002 03:30:38 -0700
Message-ID: <4306a83.0209280230.4e34f39b_at_posting.google.com>
Date: 28 Sep 2002 03:30:38 -0700
Message-ID: <4306a83.0209280230.4e34f39b_at_posting.google.com>
> SELECT
> DECODE( sign( a - 15 ),
> -1 , 'Less than 15',
> 'Grater or equal to zero' )
> FROM DUAL;
Just to correct and extend my example a bit.
The sign() return 0 if argument are equal with 0
SELECT
DECODE( sign( a - 15 ), -- Tested value
-1 , 'Less than 15', -- Compaired value and the retun value if match 0 , 'Equal to 15 'Grater than 15' ) -- Default value if no earlier match (Can be omitted)FROM DUAL; Received on Sat Sep 28 2002 - 12:30:38 CEST