In following db functions I am using returned "statement handle " and afterword just ignoring it and overwrite it with the newly returned value.
Does this cause memory leak/ or any kind of resouce leak? Can I reuse statement handle in such a way? If not, what is cleaner way to do it? ------------------------- sub getTotalDBTags (){ my $rTableListRef; my $query; my $sth; my $count=0; my $rRowCount=0; db_init(); $query = "select TableName from hourly_tables"; $sth = perform_query($query); $rTableListRef = $sth->fetchall_arrayref; $query=""; foreach $table (@$rTableListRef) { $query = "select count(*) from $table"; $sth = perform_query($query); $rRowCount = $sth->fetchall_arrayref; $count = $count + $rRowCount->[0][0]; print "count = $count\n"; } $db{handle}->disconnect(); return $count; } sub perform_query($$) { my ($query) = @_; my $sth = $db{handle}->prepare($query); unless ($sth) { ERROR ("Failed to prepare sql query: $query\n"); return undef; } unless ($sth->execute()) { ERROR ("Failed to execute sql query: $query\n)"; return undef; } return $sth; } sub db_init () { my $query = ""; if ($db{handle} = DBI->connect($db{name}, $db{user}, $db{pass})) { return(1); } else { ERROR ("Unable to connect to database $db{name}\n"); return(0); } } ----------------- Thanks, Manish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>