4 messages in com.mysql.lists.perlRe: Multiple statement handles, place...
FromSent OnAttachments
David Adam28 Jun 2002 16:49 
Jeremy Zawodny28 Jun 2002 17:22 
David Adam28 Jun 2002 18:57 
Jeremy Zawodny29 Jun 2002 00:50 
Subject:Re: Multiple statement handles, placeholders, and autoincrement
From:Jeremy Zawodny (jzaw@yahoo-inc.com)
Date:06/29/2002 12:50:27 AM
List:com.mysql.lists.perl

On Fri, Jun 28, 2002 at 06:58:07PM -0700, David Adam wrote:

Well, that is where I am confused. My take on the DBI docs was that the big advantage of preparing statements is that you can do it once and then use them over and over.

That's correct. It's more efficient to use prepared statements. DBI does less work that way.

But if you have to use a different query to get back the autoincrement value, don't you then have to prepare the first query all over again before you can use it again?

Not at all.

That was why I was using multiple connections.

You can use a single connection for many prepared queries.

my $statement1 = $dbh->prepare(...); my $statement2 = $dbh->prepare(...);

while (...) { $statement1->execute(...); $statement2->execute(...); }

That will work just fine.

Jeremy

MySQL 3.23.51: up 30 days, processed 656,836,113 queries (250/sec. avg)