Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Accessing 2 tables with 1 name
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
![]() |
![]() |