freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: craigs <s.craig AT andronics.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] dbnextrow() question
- Date: Thu, 10 Mar 2005 12:02:57 +0000
Right having problems with this, i want to exit query when i get what i want, theres over 2.4 millions records in my table so really need to get this right, can someone advise me if the following code would work.
while ((return_code = dbresults(dbconn)) != NO_MORE_RESULTS)
{
if (return_code == SUCCEED)
{
/* Bind results to program variables. */
dbbind(dbconn, 1, NTBSTRINGBIND, 0, (BYTE *)& PlaceName);
dbbind(dbconn, 2, FLT8BIND, 0, (BYTE*)&Longitude);
dbbind(dbconn, 3, FLT8BIND, 0, (BYTE*)&Latitude);
dbbind(dbconn, 4, NTBSTRINGBIND, 0, (BYTE *)& Country);
dbbind(dbconn, 5, NTBSTRINGBIND, 0, (BYTE *)& Town);
dbbind(dbconn, 6, INTBIND, (DBINT)0, (BYTE *)& SweepRadius);
/* Retrieve and print the result rows. */
while (dbnextrow(dbconn) != NO_MORE_ROWS)
{
tempDist = LatLonDistance( prev_lat, prev_lon, Latitude, Longitude );
tempDist = tempDist * 1000; //convert kilometers to meters
if ( tempDist <= SweepRadius )
{
/* Find what i'm looking for so i call a function to Insert into a table using variables above. */
InsertRecord(roadsquery);
return NO_MORE_ROWS;
}
}
dbcanquery(dbconn);
}
}
Any help would be much appreciated, thanks.
Shaun.
craigs wrote:
can i do the following using dbcanquery()
while (dbnextrow(dbconn) != NO_MORE_ROWS)
{
bind results to varialbes
if ( find what i want )
{
do something here
now exit doing the following
dbcanquery(dbconn);
}
}
will this let me exit the loop correctly with the variables still set?
Thompson, Bill D (London) wrote:
Easy, cowboy.
well, *might* is right , if you'll excuse the pun - as there is one
circumstance when it wouldn't go wrong.
On the other hand, I *might* not have had the time to go into all the
gory details :-)
Yours non-specifically,
Bill
-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Lowden, James K
Sent: 08 March 2005 17:57
To: ml AT freetds.org
Subject: RE: [freetds] dbnextrow() question
From: Thompson, Bill D (London)
Sent: Tuesday, March 08, 2005 6:01 AM
your next call to dblibrary *might* fail with a "results pending" type
error though, if you tray and do another operation on the same channel
What "might"? *Will* fail, period. The code below doesn't tell the server to stop sending rows, and doesn't
tell the library the that the result set was exhausted/cancelled.
db-lib maintains information about the state of the connection, and will
refuse to send another query. Anything else is a bug. The only exception would be if the last row fetched happened also to be
the last row sent, i.e., the last row of the result set. Some
implementations of db-lib (not FreeTDS, afaik), will note the
end-of-rowset packet and update the internal connection status
automatically. Others will not do so until dbnextrow returns
NO_MORE_ROWS. Am I missing something? --jkl
-----Original Message-----you
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of craigs
Sent: 08 March 2005 10:58
To: FreeTDS Development Group
Subject: Re: [freetds] dbnextrow() question
found an easier way of doin it.
while (dbnextrow(dbconn) != NO_MORE_ROWS)
{
if ( find what i want )
{
do something here
now exit doing the following
return NO_MORE_ROWS; // this will let you exit
}
}
Thompson, Bill D (London) wrote:
Shaun
see dbcanquery() or dbcancel() . dbcanquery looks like exactly what
want.
-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of craigs
Sent: 04 March 2005 12:19
To: FreeTDS Development Group
Subject: [freetds] dbnextrow() question
Could someone tell me how to exit this loop? I dont want to run
through
thousands of unnecessary records when i find the one i want.
while (dbnextrow(dbconn) != NO_MORE_ROWS)
{
if ( find what i want )
{
do something here
now i want to exit out off this loop
}
}
Shaun
-----------------------------------------
The information contained in this transmission may contain privileged
and confidential information and is intended only for the use of the
person(s) named above. If you are not the intended recipient, or an
employee or agent responsible for delivering this message to the
intended recipient, any review, dissemination, distribution or
duplication of this communication is strictly prohibited. If you are not
the intended recipient, please contact the sender immediately by reply
e-mail and destroy all copies of the original message. Please note that
we do not accept account orders and/or instructions by e-mail, and
therefore will not be responsible for carrying out such orders and/or
instructions.
If you, as the intended recipient of this message, the purpose of which
is to inform and update our clients, prospects and consultants of
developments relating to our services and products, would not like to
receive further e-mail correspondence from the sender, please "reply" to
the sender indicating your wishes. In the U.S.: 1345 Avenue of the
Americas, New York, NY 10105.
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds --------------------------------------------------------
If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] dbnextrow() question,
craigs, 03/04/2005
- <Possible follow-up(s)>
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/04/2005
- Re: [freetds] dbnextrow() question, craigs, 03/08/2005
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/08/2005
- Re: [freetds] dbnextrow() question, craigs, 03/08/2005
- RE: [freetds] dbnextrow() question, Lowden, James K, 03/08/2005
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/08/2005
-
Re: [freetds] dbnextrow() question,
craigs, 03/09/2005
- Re: [freetds] dbnextrow() question, craigs, 03/10/2005
-
Re: [freetds] dbnextrow() question,
craigs, 03/09/2005
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/10/2005
- Re: [freetds] dbnextrow() question, craigs, 03/10/2005
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/10/2005
-
Re: [freetds] dbnextrow() question,
craigs, 03/10/2005
- Re: [freetds] dbnextrow() question, craigs, 03/10/2005
-
Re: [freetds] dbnextrow() question,
craigs, 03/10/2005
-
RE: [freetds] dbnextrow() question,
Thompson, Bill D (London), 03/10/2005
- Re: [freetds] dbnextrow() question, craigs, 03/10/2005
- RE: [freetds] dbnextrow() question, Thompson, Bill D (London), 03/10/2005
-
re: [freetds] dbnextrow() question,
Lowden, James K, 03/10/2005
- Re: [freetds] dbnextrow() question, Brian Bruns, 03/10/2005
Archive powered by MHonArc 2.6.24.