Solved

append rows from one table to another table

Posted on 2014-10-03
5
319 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
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
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
Comment Utility
Thanks for the clue.  I will run a few trials and give you feed back tomorrow.

Thanks,
0
 

Author Comment

by:Dovberman
Comment Utility
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
Comment Utility
That helps.

Thanks,
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
>>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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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 what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now