On Sun, 6 Oct 2002, Will wrote:
> Greets Folks,
>
> I havent tried this yet, but I was wondering if it is
> possible to use multiple SQL commands in a list...
> maybe something like so...
>
> ###PREPARE AND RUN THE FIRST SQL COMMAND####
> my $sth = $dbh->prepare("SELECT foo FROM bar");
> my $thing = $sth->execute();
> ###PREPARE AND RUN A SECOND SQL COMMAND BEFORE
> DISCONNECTING###
> my $sth = $dbh->prepare("SELECT jabba FROM yadda");
> my $anotherthing = $dbh->execute;
No problem with this, except that you should not redefine $sth with
"my" the second time. $sth is already defined above.
Also, the last line should also be $sth->execute.
And if your first statement has rows to return that you haven't fetched
(as in a SELECT), do $sth->finish after the execute, to tell the db that
you're done with this particular statement.
> There's probably mistakes in my code, but the idea
> seems clear enough. My question is whether it will
> work, or how I can make it work?
It will work without a problem, assuming the above.
> Also, awhile back I recall hearing someone say I
> shouldnt use $sth->exit(); with mod_perl, and I was
> wondering if this is true? Or, if it is, why?
I've never used that.
Use:
$sth->finish();
$dbh->disconnect();
The latter (disconnect), when using Apache::DBI under mod_perl, is
overloaded to not do anything (so that your dbh is cached across
requests). In any case, all of that will function under any environment.
>
> Thanks,
>
> Will
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
---
Henri Asseily
[EMAIL PROTECTED]
Chief Technology Officer
BizRate.com
"Que les inop�rants laissent passer ceux qui font"
Achille Talon