attachments DB1 | ------------------ ---------- |T1<--+--+ |<--------| | | | | |<\ / | DB 1' | <= connection | +--(---- T2| \ / | | ------|--|-------- \ / ---------- | | \ ------|--|-------- / \ ---------- |T1<--+--+ | / \ | | | | |connect("dbi:SQLite:dbname=DB$i", "", "",{RaiseError=>1, AutoCommit=>1}); ## pointing to DB 1' connection and DB 2' connection my $joinTable = "GITAXNR"; my $form1 = "gi INTEGER not null PRIMARY KEY, ID INTEGER not null, quest BLOB not null"; $self->do_it_nr(argument => $beginn); $self->createtable_nr(table => $joinTable, form => $form1); $self->do_it_nr(argument => $commit); for(my $j = 1; $j<=2; $j++){ ### for my $j (1..2)... it works both ways my $database = "attach database 'DBi$j' as db$j"; ## attaching DB 1 and DB 2 to DB 1' in first child or DB 2' in second child $self->do_it_nr(argument => $database); $self->do_it_nr(argument => $beginn); my $insert = "insert into GITAXNR(gi,ID,quest) select GITAX.gi, GITAX.ID, NRP.quest from db$i.GITAX inner join db$j.NRP on GITAX.gi = NRP.gi"; $self->do_it_nr(argument => $insert); $self->do_it_nr(argument => $commit); } exit; } else { print "could not fork:$!"; } } foreach (@children){ waitpid($_,0) } SUBS: in new package: package Subs; ################################################## sub new { ################################################## my ($class,%arg) = @_; my $hash = {}; bless($hash,$class); } ################################################## sub do_it_nr { ################################################## my ($self, %arg) =@_; my $stm = $self->{argument}=$arg{argument}; my $st = $dbh->prepare($stm); $st ->execute(); } ################################################## sub drop_nr { ################################################## my ($self,%arg) = @_; my $arg = $self->{argument}=$arg{argument}; my $statement = "drop table if exists $arg"; $self->do_it_nr(argument => $statement); } ################################################## sub createtable_nr{ ################################################## my ($self, %arg)=@_; my $form = $self->{form}=$arg{form}; my $tabler = $self->{table}=$arg{table}; $self->drop_nr(argument => $tabler); my $stm = "create table $tabler ($form)"; $self->do_it_nr(argument => $stm); }