Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 21st, 2005, 12:45 PM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Moving data from one table to another

Hello...

I am trying to move data from one table to another table. The tables have very similar designs. I will only be moving one row at a time. How do I do this? My original idea was to retrieve each column value, stick it into a temporary variable then insert the values into the target table. However, this method is not working. Please note that I need to move multiple columns worth of data.

Thank you!

Last edited by pabloj : January 22nd, 2005 at 08:23 AM. Reason: More descriptive subject added

Reply With Quote
  #2  
Old January 21st, 2005, 07:01 PM
beunique beunique is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 50 beunique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
A simple method is to:

INSERT INTO table
AS (SELECT column1, column2
FROM table2
WHERE column1 = 'X');

if (as in your question) you need to process each record in turn you will need to create an anonomous block (or other progam unit) eg:

DECLARE
CURSOR csr_test IS
SELECT column1, column2
FROM table;
BEGIN
FOR csr_rec IN csr_test LOOP
--additional pre-insert validation here
INSERT INTO table
VALUES
(csr_rec.column1, csr_rec.column2);
END LOOP;
COMMIT;
END;

hope this helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Easy Oracle Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway