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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Inserting records from two different sources

Re: Inserting records from two different sources

From: Brian Peasland <dba_at_nospam.peasland.net>
Date: Tue, 28 Aug 2007 16:05:36 -0500
Message-ID: <46d48217$0$16330$88260bb3@free.teranews.com>


Lamar Youngers wrote:
> I am attempting to INSERT records from two identical tables in two
> different schemas into one table using a single SQL statement, Could
> one do this by using DECODE in the INSERT statement?
>
> EX:
>
> Given tables a, b_at_a, b_at_b, and c, can something like this be done?
>
> INSERT INTO c VALUES
> (DECODE (a.table_schema,
> 'a',b.column1_at_a,
> 'b',b.column1_at_b),
> DECODE (a.table_schema,
> 'a',b.column2_at_a,
> 'b',b.column2_at_b),
> ...
> );
> etc.
>

How about:

INSERT INTO destination_tables
(SELECT * FROM source_table1
  UNION
  SELECT * FROM source_table2);

Or something like that....

HTH,
Brian

-- 
===================================================================

Brian Peasland
dba_at_nospam.peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown

-- 
Posted via a free Usenet account from http://www.teranews.com
Received on Tue Aug 28 2007 - 16:05:36 CDT

Original text of this message

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