Solved

append rows from one table to another table

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
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

809 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