use strict; use warnings; use DBI; use DBU; print "$$ started\n"; my $dbh = DBI->connect('DBI:Oracle:dev', 'xxx', 'yyy', {PrintError => 1}); my $depts_sql = < sysdate and c.cd = d.id EOT my $depts_csr = $dbh->prepare($depts_sql); deptid($depts_csr); my $pid = fork; print "$$ pid = $pid\n"; if (!defined $pid) { print "$$ fork error\n"; } elsif ($pid == 0) { print "$$ child\n"; $dbh->{InactiveDestroy} = 1; # do something here in the child process exit; } deptid($depts_csr); # this call will succeed because the child has not been reaped yet waitpid $pid, 0; deptid($depts_csr); # this call will fail $dbh->disconnect; sub deptid { my ($csr) = @_; $csr->execute('WVPLPRT'); print "depts="; while (my ($deptid) = $csr->fetchrow_array) { print "$deptid,"; } print "\n"; }