[snip]
> > > >
> > > > $sth = $dbh->prepare("select ... from ... where id = ?");
> > > > $sth->execute(1); $row = $sth->fetch;
> > > > $sth->execute(2); # dies here.
Paul -- to confirm, your code which shows the problem is doing something
like this (above)? If not, can you post a snippet? I want to confirm
your pattern to make sure any fix solves the problem for you. Also,
what error do you get when you don't call finish (just to make sure)?
Jeff
[snip]
> > >
> > > The DBD::Sybase execute() method should effectively call
> finish() if
> > > the statement handle is 'Active' when execute is called.
> That's one
> > > of the main reasons the flag exists at all.
> >
> > I see this problem routinely when working with DBD::ODBC and using
> > "Select count(*)" statements within a while loop. Because I know
> > there is only one row to retrieve I don't bother running
> the fetch in
> > a loop. And, to get the code to run I always seem to have
> to at the
> > ->finish(). Are you saying that DBD::ODBC should be
> checking for me
> > if the $sth is still active, and finishing it?
>
> Yes.
>
> > If so, is something else going on in the cases
> > where I have to add the ->finish()?
>
> Seems like DBD::ODBC just isn't doing-the-right-thing.
>
> > Hope this isn't a trivial question, but I've been curious
> about this
> > for a long time given the recommendation in the DBI perldoc
> not to use
> > ->finish() and my own experience that it seems required in
> some cases.
>
> It's not a trivial question, and this thread has helped shed
> some more light on why finish persists in being an issue for people.
I agree...it especially brought to light a probable bug in DBD::ODBC --
so great!
>
> I will update the DBI docs to make it more clear that drivers
> should effectively call finish() if the statement handle is
> 'Active' when execute is called.
>
> Thanks.
>
> Tim.
>