You have 2 choices for how to do this.  If you have a database link between
the two databases, it's really easy:
$dbh->do('insert into table2 select * from table1@dblink_name');

Otherwise you need to loop it something like this:
my $sth2 = $dbh2->prepare('select * from table2');
$sth2->execute();

while (my @row = $sth2->fetchrow_array()){
     $dbh->do("insert into table " . join(',',@row));
     }

# discalimer: this is off the top of my head code....actual mileage may
vary. It also assumes identical table structures.
# obviously, the first method will be faster, but if you don't have an
existant dblink, or the permissions to create one, the second method will
have to do.

jeff


*******************************
Jeff Seger
Data Warehouse Engineer
Fairchild Semiconductor
[EMAIL PROTECTED]
*******************************


                                                                                       
                                          
                    Tim Bunce                                                          
                                          
                    <Tim.Bunce@pob       To:     [EMAIL PROTECTED]                    
                                          
                    ox.com>              cc:     [EMAIL PROTECTED]                  
                                          
                                         Subject:     (Fwd) Do you know how to select 
* from a.table1@oracle_database1 then      
                    04/18/2002            insert them into b.table2.@oracle_database2  
                                          
                    05:54 PM                                                           
                                          
                                                                                       
                                          
                                                                                       
                                          




----- Forwarded message from "Sabol, Sue Z." <[EMAIL PROTECTED]> -----

Delivered-To: [EMAIL PROTECTED]
From: "Sabol, Sue Z." <[EMAIL PROTECTED]>
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject:  Do you know how to select * from a.table1@oracle_database1 then
           insert them into b.table2.@oracle_database2
Date: Thu, 18 Apr 2002 17:20:40 -0400

Dear Tim,

Do you know how to select * from a.table1@oracle_database1 then insert them
into b.table2.@oracle_database2

Thanks!


----- End forwarded message -----




Reply via email to