RE: anyway to determine # rows before fetch loop ends and without seperate count(*)



It doesn't work according to the DBI documentation.

>From _Programming the Perl DBI_, p. 223 (for example):

>For SELECT statements, execute simply "starts" the query within the
database engine. Use one of
>the fetch methods to retrieve the data after calling execute. The execute
method does _not_ return
>the number of rows that will be returned by the query (because most
databases can't tell in advance),
>it simply returns a true value.

If you are relying on that 'feature' you are asking for trouble.

There have been discussions over this issue on the list before.

-Will

-----Original Message-----
From: Rob Craig [mailto:rcraig@xxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday 16 November 2005 17:19
To: listmail@xxxxxxxxxxxx
Cc: dbi-users@xxxxxxxx
Subject: Re: anyway to determine # rows before fetch loop ends and without
seperate count(*)


I am using DBD::mysql and I can get the number of rows by assigning the
result of the execute to a scalar:

my $rows = $sth->execute or die "Couldn't execute statement: " .
DBI->errstr;

maybe this doesn't work with DBD::Oracle?

Rob






- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.



Relevant Pages

  • Re: Finally which ORM tool?
    ... manipulate the linq query IF you're executing it at that moment. ... simply because the declaration construction was with 'CHOPS'. ... implement IEnumerablebut had an Execute() method which gave back ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: SQL stored procedure executing twice
    ... I wasn't aware that DLookupwould execute the "domain" more than once. ... caused the stored procedure to execute twice. ... Dim stDocName As String ... My pass-thru query properties ...
    (microsoft.public.access.modulesdaovba)
  • Re: Clarification on DBI module
    ... You get the same results for the second execute because the record buffer in the statment handle is not cleaned out because no execute took place. ... The sql query can have bind variables or they may not have. ... Ahhh...imagining that irresistible "new car" smell? ...
    (perl.dbi.users)
  • RE: Running action function from SELECT query
    ... Yes ADO can execute queries saved in an Access database. ... I do not know how ADO.NET works, but the developer tells me he is able to ... At any rate, I can call just a function from a query, like this: ...
    (microsoft.public.access.modulesdaovba)
  • Re: UPDATE query in Access 2003 raising error
    ... Runtime error 3066 Query must have at least one destination field. ... The SQL works fine if I use it in the QBF Design mode. ... Set qdfTemp = db.CreateQueryDef ... Elsewhere in the code I use the same technique to execute an SQL ...
    (microsoft.public.access.formscoding)