Hello Umdurman,
You call $Dbh = DBI->connect() before the while loop and $Dbh->disconnect after the loop terminates. But within the loop you call UpdateDb() which itself calls $Dbh = DBI->connect (again!) and then calls $Dbh->disconnect before returning. So the next call to $Sth->fetchrow_array in the while loop condition occurs with the db disconnected, resulting in the error message you are seeing.
This is an excellent illustration of the problem with global variables: action at a distance, making it difficult to debug. If you pass the $Dbh variable into sub UpdateDb explicitly, you will easily see that the calls to connect and disconnect within sub UpdateDb are unnecessary, as the db connection is already open, and must remain so when the subroutine returns.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: DBD problem
by Athanasius
in thread DBD problem
by Umdurman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |