Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: views if and case statements

Re: views if and case statements

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 11 Jul 2001 09:50:57 -0700
Message-ID: <9ii05h01abt@drn.newsguy.com>

In article <3B4C6F71.55A718D2_at_attws.com>, "Daniel says...
>
>CME wrote:
>
>> I am trying to convert sybase views to oracle views and I cannot find a way
>> to use 'if' or 'case' statements within a view itself
>> if there is any way this can be done or can be worked around please contact
>> me
>> thank you for any help
>
>Look at the DECODE function. That is as close as you can get.
>
>Daniel A. Morgan
>

short of using case maybe?

  1 create or replace view emp_view
  2 as

  3  select ename, empno, case when (sal < 100) then 'low'
  4                            when (sal between 101 and 500) then 'med'
  5                            when (sal between 501 and 1000) then 'high'
  6                            else 'really high'
  7                       end Salary

  8* from emp
ops$tkyte_at_ORA817.US.ORACLE.COM> /

View created.

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Wed Jul 11 2001 - 11:50:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US