Solved

append rows from one table to another table

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

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Export BLOB data from Oracle 10g 4 33
Oracle - Query Insert and Update multiple tables 5 56
Schema creation in Oracle12c 6 38
history tablespace temp usage 2 30
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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

943 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

10 Experts available now in Live!

Get 1:1 Help Now