Here is what I do:
Spencer Portee wrote:
> 1. The DBI->connect statement only has to be done once?
Declare you $dbh (database handle in a global context)
> 2. The DBI->prepare statement can be called only once and be used by many
> processes?
Sort of... Yes... But this can cause problems with disconnects. DBI doesn't
specify that the prepare will outlive the connection, so to be same you should
always re-prepare a statement after a connect -- though I have never
personally seen this behaviour.
> 3. What if the database looses connection?
sub dbcheck {
my($force) = shift;
if($force || !defined($dbh)) {
$dbh->disconnect() if($dbh);
undef $dbh;
$dbh = DBI->connect("string");
$statement ||= $dbh->prepare("SQL stuff");
}
}
sub myeximcalledroutine {
dbcheck();
# do you perl stuff.
$err = $statement->execute();
if($err) {
dbcheck(1);
$err = $statement->execute();
}
# Handle $err if it is there
}
> 4. Are there any known memory leaks?
I haven't experienced any noticable leakage.
> 5. Is the memory shared?
OS dependant and definitely NOT in the strict sense of the term "shared
memory". So, don't count on it.
--
Theo Schlossnagle
1024D/A8EBCF8F/13BD 8C08 6BE2 629A 527E 2DC2 72C2 AD05 A8EB CF8F
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7