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: Accessing 2 tables with 1 name

Re: Accessing 2 tables with 1 name

From: Nuno Souto <wizofoz2k_at_yahoo.com.au>
Date: 1 Jul 2003 19:52:58 -0700
Message-ID: <73e20c6c.0307011852.520e3a3e@posting.google.com>


mperrault_at_ingdirect.com (Mark Perrault) wrote in message news:<ee979b3c.0307011205.11a5efb1_at_posting.google.com>...
> I have 2 IDENTICAL tables (TableName_A and TableName_B) that I use in
> my production system. I have a table (TableState) with 1 row and 1
> column whose value determines which table is the "active set". (ie,
> TableState had a column named TableSet whose value is either 'A' or
> 'B').
>
> I would like to setup a view that can allow me to write queries with
> "from Tablename" where the selection of A or B is done in the
> background on the fly.
>
> Is this possible?
>

Of course. Give it a shot. Try this:

Create view my_table as
select a.col1,a.col2,etc
from TableName_A a, TableState b
where b.col1 = 'TableName_A'
union
select a.col1,a.col2,etc
from TableName_B a, TableState b
where b.col1 = 'TableName_B'
;

Or something along these lines?
Make darn sure you ONLY ever get 1 row in TableState...

Cheers
Nuno Souto
wizofoz2k_at_yahoo.com.au.nospam Received on Tue Jul 01 2003 - 21:52:58 CDT

Original text of this message

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