Solved

append rows from one table to another table

Posted on 2014-10-03
5
332 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Help on model clause 5 47
DB migration from Mssql to 12c oracle , data not loading. 3 48
Procedure syntax 5 49
Oracle Query to Find number of process consumed by a session 15 53
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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 video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

749 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