I like to use a factory to ask for a DBI handle. Like so.use strict; my $dbh = DBI->connect(XXXX); runSomeQueries(); $dbh->disconnect(); sub runSomeQueries { my $query = "select * from table"; my $sth = $dbh->prepare($query); if ( $sth->execute() ) while (my $data = $sth->fetchrow_hashref ) { runSomeSubQueries(some$$hash{ItemID}); } } sub runSomeSubQueries { my $itemID = shift; my $query = "select * from detail_table where ItemID = ?"; my $sth = $dbh->prepare($query); $sth->execute($itemID); }
-HTH
In reply to Re: Is this Bad form? (DBI)
by LanceDeeply
in thread Is this Bad form? (DBI)
by Grygonos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |