Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: oracle if else statement
On Jun 6, 10:43 am, odelya <be.spec..._at_gmail.com> wrote:
> Hi!
> I would like to write a statement using if/else for example:
> select *from table
> if value!= null then
> where value = table.value
> end if
>
> value = will be a string which might be null.
>
> im using oracle 9i
Use CASE.
SELECT <column1>, CASE WHEN <column1> = <condition1> THEN <result1> WHEN <column1> = <condition2> THEN <result2>WHEN NULL THEN 'BOB'
<column1> IDENTIFIER
---------------- -----------------
BOB
-- HTH IanReceived on Wed Jun 06 2007 - 10:46:38 CDT