Solved

append rows from one table to another table

Posted on 2014-10-03
5
340 Views
Last Modified: 2014-10-05
I have two tables. TBL_SOURCE and TBL_DEST.
TBL_SOURCE has columns col1, col2, and col3.
TBL_DEST has columns col2, and col3.
col2, and col3 have the same names and definition in both tables.

What is the syntax for Appending 12 rows from TBL_SOURCE to TBL_DEST ?

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40360735
Sample data and expected results would help a lot but maybe something like this:
insert into tbl_dest(
select col2,col3 from tbl_source
minus
select col2,col3 from tbl_dest
);
0
 

Author Comment

by:Dovberman
ID: 40360748
Thanks for the clue.  I will run a few trials and give you feed back tomorrow.

Thanks,
0
 

Author Comment

by:Dovberman
ID: 40361068
The append does not need to be executed as a single select statement.
A procedure could be used.

A plan similar to this may work:
 Build a cursor by selecting rows from the source table.
 SELECT bla, bla from source
 Count the number of rows selected
     intRowCount NUMBER;
     intRowCount   := SELECT bla, bla from source

Loop through the cursor until inRowCount is reached
       Insert into the destination table

Hopefully a bulk insert statement would work.

I cannot try these ideas until Monday.
0
 

Author Closing Comment

by:Dovberman
ID: 40362093
That helps.

Thanks,
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40362554
>>Hopefully a bulk insert statement would work.

Will it work, maybe, but why bother?

Why create an in-memory table just to loop through the rows when the cursor above does it all for you?

Just because you 'can' do something doesn't mean it is a good idea...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question