On Tue, Jul 13, 2004 at 05:04:17PM +0200, Michael Peppler wrote:
> On Tue, 2004-07-13 at 16:46, Tim Bunce wrote:
> > On Tue, Jul 13, 2004 at 03:26:13PM +0200, Michael Peppler wrote:
> 
> > > Sample code:
> > > 
> > >   my $dbh = DBI->connect('dbi:Sybase:server=MY_SERVER;bulkLogin=1',
> > > $user, $pwd);
> > >   my $sth = $dbh->prepare('insert the_table values(?, ?, ?, ?, ?)",
> > >                           syb_bcp_attribs => { identity_flag => 0,
> > >                                                identity_column => 0 }});
> > >   while(<DATA>) {
> > >     chomp;
> > >     my @row = split(/\|/, $_);   # assume a pipe-delimited file...
> > >     $sth->execute(@row);
> > >   }
> > >   $dbh->commit;
> > >   print "Sent ", $sth->rows, " to the server\n";
> > >   $sth->finish;
> > 
> > > AutoCommit is ignored for this operation (it is always off).
> > 
> > Could you make it warn if AutoCommit is on, and include $dbh->begin_work
> > in your examples? That would make the code more portable.
> 
> I'll check.

Thanks.

> > > $sth->rows returns the number of rows committed for the latest call to
> > > $dbh->commit().
> > > $sth->execute() will fail if there are any data conversion errors.
> > 
> > > $sth->finish will rollback any non-committed rows.
> > 
> > What's the role of finish() here? Is it needed?
> 
> Right now the finish() call is necessary, because I just noticed that
> I'm missing some cleanup code in the DESTROY() call...

Okay.

> But for the "real" version the finish() call is optional, and is just
> there to be complete and to behave in a way that would be (to me)
> consistent with other situations.

Does finish() for INSERT statements do anything in DBD::Sybase?

Tim.

Reply via email to