Re: UPDATE: How to test status of handler sth?

Hi,

Ok, how about this. Show me an example where you can prove the database
connection still exists, but you can't fetch rows from $sth on a successful
query.. Everytime I have ever had a problem fetching rows, either the query
didn't return any, or the dbconnection died. 

I guess this might not work with some DBs or drivers? But I have always just
used my $returned_rows = $sth->execute(); with mysql DBD::mysql
and at least in my case and situation, $returned_rows gives the number of
rows returned by the query or 0E0 if nothing. 


Eric 

At 07:26 PM 10/24/03 -0700, perl@swanmail.com wrote:
>Let's re-state the question:
>
>If I can test $dbh using $dbh->ping(), then what is a test for $sth after
>the execute command? Assume we don't know if the execute is good or bad
>for a SELECT?

(250) 655 - 9513 (PST Time Zone)

"Inquiry is fatal to certainty." -- Will Durant 




0
ef
10/25/2003 1:27:07 AM
perl.dbi.users 11085 articles. 1 followers. Follow

2 Replies
157 Views

Similar Articles

[PageSpeed] 26

I'm messing with this code so much that I can't trace it down. But I will
tell you that I get a huge number, 4698765..., when I do a $sth->rows()

I do believe the $dbh connection is still good but something is wrong with
the $sth. Which means I get no rows fetched when I am expecting.

btw, I'm using redhat 9/mysql canned installation.

Sorry to post like this but every now and then I run into this error which
causes the code to break upon the call $sth->fetchrow_array().

Thanks for following-up, I'm not trying to prove anything. Just trying to
figure out what is happening. Most likely I have a bad reference somewhere
because I'm not either passing the handler around correctly.

-thanks



> Hi,
>
> Ok, how about this. Show me an example where you can prove the database
> connection still exists, but you can't fetch rows from $sth on a
> successful
> query.. Everytime I have ever had a problem fetching rows, either the
> query
> didn't return any, or the dbconnection died.
>
> I guess this might not work with some DBs or drivers? But I have always
> just
> used my $returned_rows = $sth->execute(); with mysql DBD::mysql
> and at least in my case and situation, $returned_rows gives the number of
> rows returned by the query or 0E0 if nothing.
>
>
> Eric
>
> At 07:26 PM 10/24/03 -0700, perl@swanmail.com wrote:
>>Let's re-state the question:
>>
>>If I can test $dbh using $dbh->ping(), then what is a test for $sth after
>>the execute command? Assume we don't know if the execute is good or bad
>>for a SELECT?
>
> (250) 655 - 9513 (PST Time Zone)
>
> "Inquiry is fatal to certainty." -- Will Durant
>
>
>
>
>



-----------------------------------------
eMail solutions by 
http://www.swanmail.com
0
perl
10/25/2003 6:08:10 AM
On Fri, 24 Oct 2003 23:08:10 -0700 (PDT) perl@swanmail.com wrote:

> I'm messing with this code so much that I can't trace it down.  But I
> will tell you that I get a huge number, 4698765..., when I do a
> $sth->rows()

Search for "rows" in http://search.cpan.org/dist/DBI/DBI.pm . rows()
can't be called unless the variable $sth is a blessed statement handle
object.

If you can call $sth->rows() without a fatal error, you have at least
established that $sth is still a blessed DBI statement handle.

> I do believe the $dbh connection is still good but something is wrong
> with the $sth.  Which means I get no rows fetched when I am expecting.

It would be easier for us to judge if you provided a sample of the code
that demonstrates the issue.

> btw, I'm using redhat 9/mysql canned installation.

That's a start.  Up to now I had no idea which RDBMS you were using.

> Sorry to post like this but every now and then I run into this error
> which causes the code to break upon the call $sth->fetchrow_array().

What error is in $sth->errstr?  The same value is in $DBI::errstr until
another DBI method resets it.  Unless you check, you have no clue what's
going wrong.

> Thanks for following-up, I'm not trying to prove anything.  Just trying
> to figure out what is happening.  Most likely I have a bad reference
> somewhere because I'm not either passing the handler around correctly.

Checking for errors at each point would make it possible to do more than
randomly speculate.  See
http://search.cpan.org/dist/DBI/DBI.pm#Simple_Examples for examples of
explicit and automatic error checking of several method calls.

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

0
mchase
10/25/2003 10:32:38 AM
Reply:

Similar Artilces:

[perl5-dbi/DBI-Test] 673485: Add DBI::Test::CheckUtil. Update README. More poli...
----==_mimepart_5325a1ef8f778_1aa0effd44242e7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: 67348591c643d7bcbbd8a5286d760daf1602873e https://github.com/perl5-dbi/DBI-Test/commit/67348591c643d7bcbbd8a5286d760daf1602873e Author: Tim Bunce <Tim.Bunce@pobox.com> Date: 2014-03-16 (Sun, 16 Mar 2014) Changed paths: M sandbox/tim/README.pod A sandbox/tim/lib/DBI/Test/CheckUtil.pm M sandbox/tim/lib/DBI/Test/VariantDriver/Base.pm A sandbox...

How to test status of handler sth?
How can I test the status of $sth itself? A scenario is that a $sth is passed from a sub. And now, I have a $sth. Of course $sth->rows return 0 or whatever int row. However, a test using $sth->rows is not good when something is wrong. It return some large number. So How can I test to see if its bad or good without access to previous calls? thanks ----------------------------------------- eMail solutions by http://www.swanmail.com On Wed, 22 Oct 2003 22:18:18 -0700 (PDT) perl@swanmail.com wrote: > How can I test the status of $sth itself? > > A scenario ...

re: re: test
test ...

RE: Test::User, Test::Symlink
> On Tue, Jun 28, 2005 at 03:24:51PM +0100, Clayton, Nik wrote: > > user_ok(name =3D> 'nik', uid =3D> 1000, shell =3D> '/bin/tcsh', > > 'Check nik\'s account'); >=20 > My only thought is I would use a hash ref. >=20 > user_ok( { name =3D> 'nik', uid =3D> 1000, shell =3D> '/bin/tcsh' }, > "Check nik's account" ); >=20 > Just to make it a bit clearer what's going on. A hash followed by a=20 > scalar as an argument list is a little weird. Ye-es. ...

[perl5-dbi/DBI-Test] a2d1b2: create separate tests for DBI and DBI::Mock ...
----==_mimepart_51f946a54bb1b_2af891bd4c100430 Date: Wed, 31 Jul 2013 10:17:25 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <51f946a54c721_2af891bd4c100582@hookshot-fe3-pe1-prd.aws.github.net.mail> Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: a2d1b22d134be0ca353e0f0b312fb14da24c798e https://github.com/perl5-dbi/DBI-Test/commit/a2d1b22d134be0ca353e0f0b312fb14da24c798e Author: Jens Rehsack <sno@netbsd.org> Date: 2013-07-31 (Wed, 31 Jul 2013) Changed ...

Getting off the DBI-Users mailing list [was: Re: SQLite 3.3.16 nulls test results]
------=_Part_26231_30502823.1178195436876 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline The email headers say: List-Unsubscribe: <mailto:dbi-users-unsubscribe@perl.org> List-Help: <mailto:dbi-users-help@perl.org> Send email to dbi-users-unsubscribe@perl.org from your registered email acccount, or go to the web site dbi.perl.org and unsubscribe from there. On 5/2/07, OMAR BARADI <omar_baradi@hotmail.com> wrote: > > I have been trying to unsubscribe. I followed the directions...

RE: Status of DBI 1.35 (was: Install of DBI)
There is one outstanding issue that I am aware of. We reported a problem setting the RootClass attribute in DBI v1.30, which was addressed in v1.31. Unfortunately, the fix has a small problem. Here is the original message from rt.cpan.org: Mon Nov 18 17:09:05 2002 guest - Ticket created [Reply] [Comment] Subject: Cannot set RootClass attribute to a package in the same file Given this example: --START-- package Foo::DBIx; our @ISA = qw(DBI); package Foo::DBIx::db; our @ISA = qw(DBI::db); package Foo::DBIx::st; our @ISA = qw(DBI::st); package main; u...

RE: build fails (Was: RE: Updated Platforms Status)
> From: Brent Dax [mailto:brentdax@cpan.org] > Henrik Tougaard: > # > ------------------------------ > # > CORE PLATFORMS > # > ------------------------------ > # > OpenVMS (Alpha) > # > ?? > # ....[snip]... > As a stopgap measure, > > ($^O eq 'VMS' ? " /Include=[.include]" : " -I./include") > > ought to work (or something like it--I'm not a VMS guy). It does work. We get a tiny bit further.... The same call to $c{cc} has a 'hand-written' -o flag. That's wrong again - it should ...

[perl5-dbi/dbi] b6bfd4: Inital test files. To be updated
----==_mimepart_5232e49dbf587_240e997d4865097 Date: Fri, 13 Sep 2013 03:10:37 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <5232e49dc0601_240e997d48651ed@hookshot-fe3-pe1-prd.aws.github.net.mail> Branch: refs/heads/dbi-test-conditional Home: https://github.com/perl5-dbi/dbi Commit: b6bfd459941b3576798a1a60d8a90d1fe446ecfd https://github.com/perl5-dbi/dbi/commit/b6bfd459941b3576798a1a60d8a90d1fe446ecfd Author: Joakim <bannan@gmail.com> Date: 2013-09-13 (Fri, 13 Sep 2013) Changed pa...

[perl5-dbi/DBI-Test] f963e7: Updates to DESIGN.md
----==_mimepart_51c81ffd6055_4e9513d1de0418c1 Date: Mon, 24 Jun 2013 03:31:25 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <51c81ffd6d30_4e9513d1de04195c@hookshot-fe6-pe1-prd.aws.github.net.mail> Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: f963e73b4bfa4fe25a4995fabcef28376fba8b6e https://github.com/perl5-dbi/DBI-Test/commit/f963e73b4bfa4fe25a4995fabcef28376fba8b6e Author: Tim Bunce <Tim.Bunce@pobox.com> Date: 2013-06-24 (Mon, 24 Jun 2013) Changed ...

Re: Re: [PATCH] Get DBI to pass tests with bleadperl
--Next_1161752126---0-59.160.240.216-26545 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =A0=0AHi Moderator,=0A=0AI am unable to unsubscribe from this group.=0A=0A= Can anyone help.=0A=0AThanks,=0AMurali=0A=0AOn Tue, 24 Oct 2006 Andreas J.K= oenig wrote :=0A> >>>>> On Mon, 23 Oct 2006 09:10:38 -0500, Steve Peters <s= teve@fisharerojo.org> said:=0A>=0A> > I seemed to get it to compile, but = it blew up on assertions on assertions.=0A> > With some help from Nichola= s C...

[perl5-dbi/DBI-Test] 36895c: Updates to DESIGN.md
----==_mimepart_51c80faa8e2a2_12df981de01050ae Date: Mon, 24 Jun 2013 02:21:46 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <51c80faa8ed40_12df981de010514@hookshot-fe2-pe1-prd.aws.github.net.mail> Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: 36895c2da2f357de357937013b1a195169bb8312 https://github.com/perl5-dbi/DBI-Test/commit/36895c2da2f357de357937013b1a195169bb8312 Author: Tim Bunce <Tim.Bunce@pobox.com> Date: 2013-06-24 (Mon, 24 Jun 2013) Changed...

[perl5-dbi/dbi] 6b72ff: Inital test files. To be updated
----==_mimepart_516ac877bbc71_6d8eacf134820bc Date: Sun, 14 Apr 2013 08:17:11 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <516ac877bdcac_6d8eacf134821b7@hookshot-fe2-pe1-prd.aws.github.net.mail> Branch: refs/heads/dbi-test Home: https://github.com/perl5-dbi/dbi Commit: 6b72ffca7ef7cf059e30c3c1d7dd6cf1a6def2fc https://github.com/perl5-dbi/dbi/commit/6b72ffca7ef7cf059e30c3c1d7dd6cf1a6def2fc Author: Joakim <bannan@gmail.com> Date: 2013-04-14 (Sun, 14 Apr 2013) Changed paths: A ...

RE: Re: [wxperl-users] Re: Re: EVT_QUERY_END_SESSION
you putted the EVT_CLOSE to the wrong place... or do you have a reason why you need it to be there? $app ist not the window, but you could use EVT_CLOSE on $frame too. i changed your minimal sample that it works. hope it helps greeting Marco ---- use Wx; ########################### package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my( $this ) = @_; my( $frame ) = MyFrame->new( "Minimal wxPerl app", Wx::Point->new( 50, 50 ), Wx::Size->new( 450, 350 ) ); ...

Web resources about - Re: UPDATE: How to test status of handler sth? - perl.dbi.users

Resources last updated: 1/16/2016 10:10:53 AM