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

Home -> Community -> Usenet -> c.d.o.server -> Re: Is it possible for me to create such a view?

Re: Is it possible for me to create such a view?

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: Thu, 08 Apr 1999 17:51:33 GMT
Message-ID: <371325c6.1797543@netnews.worldnet.att.net>


>
> I am now trying to create a view from z1 whose second column's value is
>decided by some conditions.
> 1. create a view z1_view1 whose second column's
>value is TRUE if z1's second column's valuse is less then 100, else FALSE.
>In my case, the out put should be:
>z1_view1:
>1 TRUE
>2 FALSE
>3 FALSE
Oracle doesn't support boolean types for tables, so let's use 0 for false and 1 for true. You could do the following:

create or replace view z1_view1 as
select z1_c1, decode(sign(z1_c2-100)),-1,1,0) from z1;

> 2. create a view z1_view2 whose second column's value is TRUE if z1's first
>column's value exists in z2, else FALSE. In my case, the output should be:
>1 FALSE
>2 TRUE
>3 FALSE
create view z1_view2 as
select z1_c1,decode(z2_c1,null,0,1)
from z1, z2
where z1_c1 = z2_c1(+);

I think these will work. At least they should get you started. The DECODE function is probably the key to what you want to do. Read up on it in the SQL reference manual.

Jonathan Received on Thu Apr 08 1999 - 12:51:33 CDT

Original text of this message

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