Skip to Content.
Sympa Menu

freetds - RE: Help - I am going crazy...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: RE: Help - I am going crazy...
  • Date: Mon, 5 Aug 2002 16:55:56 +0200


>
> I can't find a solution to getting the current number of rows
> from a select
> query. I can't believe that there isn't one -- no one would
> be using this...
>
> I am using the freeTDS from CVS and the odbc connection - I
> am using it
> through PHP. I need to be able to get the number of rows
> before I fetch all
> the rows or I need to be able to backup to the first row if I
> need to loop
> through all the fetches (boy that would be slow).
>
> I have been trying to get a second select after the first one
> executes with
> the SELECT @@ROWCOUNT - which if done after the fetches
> returns just fine.
> However, if I try to do the execute before the fetch, that
> fails - there are
> results pending.
>
> For some reason, even doing a select COUNT(*) from (other
> query) derivedtbl
> - this seems to take for ever if I do the two queries one
> right after the
> other, but run by itself -- it is fine...
>
> Wow -- this is a royal pain...
>
> Please any suggestions are welcome and appreciated...!
>
Sybase and MSSQL do not return rowcount until return all rows.
So a solution could be

SELECT fields INTO #tmp FROM ...
SELECT COUNT(*) FROM #tmp
SELECT * FROM #tmp
DROP #tmp

(note that #tmp is dropped automatically at the end of connection)

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================




Archive powered by MHonArc 2.6.24.

Top of Page