#!/usr/bin/perl use Parallel::ForkManager; use DBI; use strict; my $dbh=DBI->connect("dbi:Oracle:dbname","username","password",{RaiseError => 1 , PrintError => 0}); my $dbh1=DBI->connect("dbi:Oracle:dbname","username","password",{RaiseError => 1 , PrintError => 0}); my $dbh2=DBI->connect("dbi:Oracle:dbname","username","password",{RaiseError => 1 , PrintError => 0}); my $dbh3=DBI->connect("dbi:Oracle:dbname","username","password",{RaiseError => 1 , PrintError => 0}); my ($sth1, $sth2, $sth3); # statement handles my ($sqlstmt1, $sqlstmt2, $sqlstmt3); # statements to be executed my @num_array = ("1", "2", "3"); my $mid = $#num_array; my $t = localtime(); my $pm = new Parallel::ForkManager($mid + 1); for (my $mid_cnt = 0; $mid_cnt <= $mid; $mid_cnt++) { $pm->start and sleep 30 and next; ## Beginning of parallel process. print $x "For Number $num_array[$mid_cnt]:\n"; if ($num_array[$mid_cnt] == 0) { $t = localtime(); print "Calling procedure for Number $num_array[$mid_cnt] at $t\n"; $sqlstmt1 = "BEGIN TEST_PROC($num_array[$mid_cnt]); end;"; $sth1 = $dbh1->do($sqlstmt1) or die $dbh1->errstr; $t = localtime(); print "Done with procedure for Number $num_array[$mid_cnt] at $t\n\n"; } elsif ($num_array[$mid_cnt] == 1) { $t = localtime(); print "Calling procedure for Number $num_array[$mid_cnt] at $t\n"; $sqlstmt2 = "BEGIN TEST_PROC($num_array[$mid_cnt]); end;"; $sth2 = $dbh2->do($sqlstmt2) or die $dbh2->errstr; $t = localtime(); print "Done with procedure for Number $num_array[$mid_cnt] at $t\n\n"; } else { $t = localtime(); print "Calling procedure for Number $num_array[$mid_cnt] at $t\n"; $sqlstmt3 = "BEGIN TEST_PROC($num_array[$mid_cnt]); end;"; $sth3 = $dbh3->do($sqlstmt3) or die $dbh3->errstr; $t = localtime(); print "Done with procedure for Number $num_array[$mid_cnt] at $t\n\n"; } $pm->finish; ## End of parallel process. } $pm->wait_all_children; $dbh1 -> disconnect; $dbh2 -> disconnect; $dbh3 -> disconnect;