--- test.pl --- use DBI; use DBD::Oracle qw(:ora_session_modes); my $tbs_name='T2010'; my $dbh = DBI->connect("DBI:Oracle:","","",{ora_session_mode => ORA_SY +SDBA,RaiseError=>1,AutoCommit=>1,PrintError=>1}); my $sql = sprintf qq{SELECT DISTINCT TABLE_OWNER,TABLE_NAME FROM SYS.D +BA_TAB_PARTITIONS WHERE TABLESPACE_NAME=? AND TABLE_OWNER='FOO'}; my $sql_h = $dbh->prepare($sql); $sql_h->execute($tbs_name); $sql_ref = $sql_h->fetchall_arrayref; afork ($sql_ref,10,\&initialize_control_data,$dbh); $dbh->disconnect(); exit(0); sub afork (\@$&&) { my ($data,$max,$code,$cdbh) = @_; my $c = 0; foreach my $data (@$data) { wait unless ++$c <= $max; die "Fork failed: $!\n" unless defined (my $pid = fork); $cdbh->{InactiveDestroy} = 1 if ($pid); exit $code->($cdbh,@$data[0],@$data[1]) unless $pid; } 1 until -1 == wait; } sub initialize_control_data { my ($edbh,$schema,$table) = @_; print "$schema,$table\n"; } --- end --- % test.pl FOO,TABLE1 ... FOO,TABLEn DBD::Oracle::db disconnect failed: ORA-03135: connection lost contact +(DBD ERROR: OCISessionEnd) at ./test.pl line 20. DBD::Oracle::db disconnect failed: ORA-03135: connection lost contact +(DBD ERROR: OCISessionEnd) at ./test.pl line 20.
In reply to help with afork and dbi by bplegend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |