Problem with disconnect

Problem with disconnect

am 29.04.2004 12:19:18 von Jan Eden

Hi,

I receive the following error using $dbh->disconnect:

DBI::db=3DHASH(0x812938)->disconnect invalidates 1 active statement handle =
(either destroy statement handles or call finish on them before disconnecti=
ng) at ./pdfshorten.pl line 37.

I do not understand this. It's an extremely simple test script like this. T=
he relevant part is this:

---
my $dbh =3D DBI->connect("dbi:mysql:$db:$server", $username, $password, { =
RaiseError =3D> 1 });

my $query =3D "SELECT page_id, content FROM pages WHERE page_id =3D 1583";=
=20
my $sth =3D $dbh->prepare($query);
$sth->execute();
my ($id, $content) =3D $sth->fetchrow_array;
# modify $content here
my $query2 =3D "UPDATE pages SET content =3D $content WHERE page_id =3D $id=
";
my $sth2 =3D $dbh->prepare($query2);
$sth2->execute();

$dbh->disconnect;
---

In other scripts (used in conjuction with CGI), I never got a warning like =
this.

Grateful for explanations,

Jan
--=20
There are 10 kinds of people: those who understand binary, and those who d=
on't

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org

Re: Problem with disconnect

am 29.04.2004 13:27:00 von David Dick

try

Jan Eden wrote:
> Hi,
>
> I receive the following error using $dbh->disconnect:
>
> DBI::db=HASH(0x812938)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ./pdfshorten.pl line 37.
>
> I do not understand this. It's an extremely simple test script like this. The relevant part is this:
>
> ---
> my $dbh = DBI->connect("dbi:mysql:$db:$server", $username, $password, { RaiseError => 1 });
>
> my $query = "SELECT page_id, content FROM pages WHERE page_id = 1583";
> my $sth = $dbh->prepare($query);
> $sth->execute();
> my ($id, $content) = $sth->fetchrow_array;
> # modify $content here

$sth->finish();

> my $query2 = "UPDATE pages SET content = $content WHERE page_id = $id";
> my $sth2 = $dbh->prepare($query2);
> $sth2->execute();

$sth2->finish();

>
> $dbh->disconnect;
> ---
>
> In other scripts (used in conjuction with CGI), I never got a warning like this.
>
> Grateful for explanations,
>
> Jan

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Problem with disconnect

am 29.04.2004 13:27:00 von David Dick

try

Jan Eden wrote:
> Hi,
>
> I receive the following error using $dbh->disconnect:
>
> DBI::db=HASH(0x812938)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ./pdfshorten.pl line 37.
>
> I do not understand this. It's an extremely simple test script like this. The relevant part is this:
>
> ---
> my $dbh = DBI->connect("dbi:mysql:$db:$server", $username, $password, { RaiseError => 1 });
>
> my $query = "SELECT page_id, content FROM pages WHERE page_id = 1583";
> my $sth = $dbh->prepare($query);
> $sth->execute();
> my ($id, $content) = $sth->fetchrow_array;
> # modify $content here

$sth->finish();

> my $query2 = "UPDATE pages SET content = $content WHERE page_id = $id";
> my $sth2 = $dbh->prepare($query2);
> $sth2->execute();

$sth2->finish();

>
> $dbh->disconnect;
> ---
>
> In other scripts (used in conjuction with CGI), I never got a warning like this.
>
> Grateful for explanations,
>
> Jan

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Problem with disconnect

am 29.04.2004 14:58:27 von Rudy Lippan

On Thu, 29 Apr 2004, David Dick wrote:

> > my $query2 = "UPDATE pages SET content = $content WHERE page_id = $id";
> > my $sth2 = $dbh->prepare($query2);
> > $sth2->execute();
>
> $sth2->finish();

This finish should not be needed. And it could all be replaced with a simple
$sth2->do().

Rudy


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Problem with disconnect

am 29.04.2004 14:58:27 von Rudy Lippan

On Thu, 29 Apr 2004, David Dick wrote:

> > my $query2 = "UPDATE pages SET content = $content WHERE page_id = $id";
> > my $sth2 = $dbh->prepare($query2);
> > $sth2->execute();
>
> $sth2->finish();

This finish should not be needed. And it could all be replaced with a simple
$sth2->do().

Rudy


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Problem with disconnect

am 01.05.2004 22:48:24 von Jan Eden

Thanks, Rudy and David,

Rudy Lippan wrote on 29.04.2004:

>On Thu, 29 Apr 2004, David Dick wrote:
>
>>>my $query2 =3D "UPDATE pages SET content =3D $content WHERE page_id =3D
>>>$id"; my $sth2 =3D $dbh->prepare($query2); $sth2->execute();
>>
>>$sth2->finish();
>

That did the trick.=20

>This finish should not be needed. And it could all be replaced with
>a simple $sth2->do().

You're right, of course.

- Jan
--=20
A common mistake that people make when trying to design something completel=
y foolproof is to underestimate the ingenuity of complete fools.

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org

Re: Problem with disconnect

am 01.05.2004 22:48:24 von Jan Eden

Thanks, Rudy and David,

Rudy Lippan wrote on 29.04.2004:

>On Thu, 29 Apr 2004, David Dick wrote:
>
>>>my $query2 =3D "UPDATE pages SET content =3D $content WHERE page_id =3D
>>>$id"; my $sth2 =3D $dbh->prepare($query2); $sth2->execute();
>>
>>$sth2->finish();
>

That did the trick.=20

>This finish should not be needed. And it could all be replaced with
>a simple $sth2->do().

You're right, of course.

- Jan
--=20
A common mistake that people make when trying to design something completel=
y foolproof is to underestimate the ingenuity of complete fools.

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org