> On Tue, Aug 15, 2000 at 03:26:03PM +0400, Vladislav Safronov wrote:
> > Hi,
> > 
> > Could you have a look at the lines and answer the question ..
> > ---
> > sub foo {
> >     my $dbh = shift;
> > 
> >     my $sql = ...
> > 
> >     my $sth = $dbh->prepare($sql);
> >     $sth->execute;
> >     $sth->finish;
> > }
> > ===
> > Do I always need to call $sth->finish?
> 
> You *never* need to call finish on non-select statements.
> (If you do, it's a driver bug.)
> 
> > Wouldn't it be automaticly called when
> > sub foo ends (when my variable $sth get destroyed)?
> 
> Finish marks the end of *fetching*, not the end of life of the handle.

So I can freely overwrite the handle with new one, since it's not the end
of life of the handle, can't I?
==
        my $sql = "select .."
 
        my $sth = $dbh->prepare($sql);
        $sth->execute;
        .. fetch just some (not all) data
        my $newsql = "select .."
        $sth = $dbh->prepare($newsql);
        $sth->execute;
==
and this code should work with troubles ...

Vlad.

Reply via email to