Home » SQL & PL/SQL » SQL & PL/SQL » Copy data from table 1A,1B to table 2A,2B & Update table 1A,1B
Copy data from table 1A,1B to table 2A,2B & Update table 1A,1B [message #201811] Mon, 06 November 2006 20:46 Go to next message
voralux
Messages: 72
Registered: January 2006
Member

Please help me,
I have 4 Table = 1A,1B, 2A,2B
No. of Column & DataType : 1A = 2A, 1B = 2B

I would like 1. Copy Data from 1A to 2A and 1B to 2B (where 1A.status = "COPY" and 2A.Status = "COPY")

2. Update data from (where 1A.status = "COPY" and 2A.Status = "COPY") to (where 1A.status = "COPYCOMPLETED" and 2A.Status = "COPYCOMPLETED")





Re: Copy data from table 1A,1B to table 2A,2B & Update table 1A,1B [message #201848 is a reply to message #201811] Tue, 07 November 2006 01:13 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One phase solution:
INSERT INTO 2A
  (status, col2, col3, ...)
  (SELECT 'COPYCOMPLETED', col2, col3, ...
   FROM 1A
   WHERE status = 'COPY'
  );

Two phase solution (perhaps easier if column list is really, really large and table, on the other hand, isn't that large):
INSERT INTO 2A 
  SELECT * FROM 1A 
    WHERE status = 'COPY';

UPDATE 2A SET status = 'COPYCOMPLETED';

Previous Topic: Sample Data model .
Next Topic: procedures
Goto Forum:
  


Current Time: Sat Dec 10 09:06:21 CST 2016

Total time taken to generate the page: 0.09273 seconds