On Fri, 2003-01-03 at 02:42, Tim Bunce wrote:
> On Fri, Jan 03, 2003 at 05:01:53AM +0200, Boris Penchev wrote:
> > Dear All,
> > 
> > 1. Yes, I know that if you have prepare you can make a lot of execute of it, and 
>that i can make this query in start of my program
> > or in one module.
> > 2. I think that is a good idea to declare $id and $name in while loop, because I 
>use it only in this loop
> > 3. I recommend you to use finish() method
> 
> I recommend you don't unless you know that the code will not read
> all the rows that would be selected.

Unfortunately when using DBD::Sybase the following code breaks, even if
there is only one row to fetch for the first iteration:

$sth = $dbh->prepare("select ... from ... where id = ?");
$sth->execute(1);
$row = $sth->fetch;
$sth->execute(2);   # dies here.

The reason is that the Sybase client libraries (and DBD::Sybase) can
only tell that *all* the results have been fetched once fetch() returns
an empty/undef array.

Adding a  $sth->finish before the second execute() call fixes the
problem, of course.

Michael
> -- 
> Michael Peppler                              Data Migrations, Inc.
> [EMAIL PROTECTED]                 http://www.mbay.net/~mpeppler
> Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or 
> long term contract positions - http://www.mbay.net/~mpeppler/resume.html

Reply via email to