On Thu, 2003-10-23 at 13:00, Levon Barker wrote: > Should I be making new statement handlers for every new request?
You don't have to, but if you don't and the Oracle connection gets lost and Apache::DBI reconnects, your stale statement handles will all fail. The best thing to do is use prepare_cached. This will use an already prepared statement handle if possible. > package SomeModuleWhichShowsUpAsaAPage; > > my $dbh = DBI->connect ( 'dbi:Oracle:paprodi','test', 'test', > { > RaiseError => 1, > AutoCommit => 0 > } > ) || die "Oracle database connection not made"; > > my $sql = "select title from industry where id = ?"; > my $sth = $dbh->prepare($industrySql); [...] > sub get_industry_str { > my $id = shift; > $sth->execute($id); > my $title; > $sth->bind_col( 1, \$title); > $while ($sth->fetch) { > } > return $title; > } Do you load this module from startup.pl or httpd.conf? If you load this before apache forks, it will create a database connection and statement handle, and then try to use them after the fork. (Your sub that refers to $sth is a closure.) You should not open a database handle before the fork. Instead, open it in your handler method, and create a new $sth (with prepare_cached). Apache::DBI and prepare_cached will take care of caching these for you. - Perrin