BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Last record not being processed

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
Ney André de Mello Zunino
Guest





PostPosted: Tue Jul 18, 2006 5:38 am    Post subject: Last record not being processed Reply with quote



Hello.

I have a very basic loop over a query object (TADOQuery) which is not
behaving as expected. It is contained in a member function which is
supposed to check whether any of the records contain a non-zero value in
a given column ("correlation"):

bool TdmMonteCarlo::checkCorrelation() const
{
aqOperations->DisableControls();
bool correlation = false;
int idCurrent = aqOperations->FieldByName("id")->AsInteger;

aqOperations->First();
while (!aqOperations->Eof)
{
if (aqOperations->FieldByName("correlation")->AsFloat != 0.0)
{
correlation = true;
break;
}
aqOperations->Next();
}

aqOperations->Locate("id",
AnsiString(idCurrent).c_str(),
TLocateOptions());
aqOperations->EnableControls();
return correlation;
}

The problem is that the last record is not being processed. In other
words, the /Eof/ property is becoming true just as the cursor moves to
the last record, not when it tries to go beyond it, as things normally
work. Does anybody have any idea of what could be causing this? I read
somewhere else that Eof might behave strangely when key fields are
modified, but the loop in question is a read-only one.

Thank you for any feedback.

--
Ney André de Mello Zunino
Back to top
Mark Guerrieri
Guest





PostPosted: Wed Jul 19, 2006 8:45 pm    Post subject: Re: Last record not being processed Reply with quote



What version are you using?

Do you have any filters in place?

Mark

"Ney André de Mello Zunino" <zunino (AT) inf (DOT) ufsc.br> wrote in message
news:44bc2d8e$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hello.

I have a very basic loop over a query object (TADOQuery) which is not
behaving as expected. It is contained in a member function which is
supposed to check whether any of the records contain a non-zero value in a
given column ("correlation"):

bool TdmMonteCarlo::checkCorrelation() const
{
aqOperations->DisableControls();
bool correlation = false;
int idCurrent = aqOperations->FieldByName("id")->AsInteger;

aqOperations->First();
while (!aqOperations->Eof)
{
if (aqOperations->FieldByName("correlation")->AsFloat != 0.0)
{
correlation = true;
break;
}
aqOperations->Next();
}

aqOperations->Locate("id",
AnsiString(idCurrent).c_str(),
TLocateOptions());
aqOperations->EnableControls();
return correlation;
}

The problem is that the last record is not being processed. In other
words, the /Eof/ property is becoming true just as the cursor moves to the
last record, not when it tries to go beyond it, as things normally work.
Does anybody have any idea of what could be causing this? I read somewhere
else that Eof might behave strangely when key fields are modified, but the
loop in question is a read-only one.

Thank you for any feedback.

--
Ney André de Mello Zunino
Back to top
Ney André de Mello Zunino
Guest





PostPosted: Thu Jul 20, 2006 12:37 am    Post subject: Re: Last record not being processed Reply with quote



Mark Guerrieri wrote:

Thanks for responding.

Quote:
What version are you using?

Borland C++ Builder 6 running on Windows XP (SP2).

Quote:
Do you have any filters in place?

None. It is a plain TADOQuery object with a simple select such as:

SELECT * FROM Operations WHERE well_id = <id>

Best regards,

--
Ney André de Mello Zunino
Back to top
Mark Richards
Guest





PostPosted: Thu Jul 20, 2006 3:36 am    Post subject: Re: Last record not being processed Reply with quote

Quote:
while (!aqOperations->Eof)
{
if (aqOperations->FieldByName("correlation")->AsFloat != 0.0)
{
correlation = true;
break;
}
aqOperations->Next();
}

Have you checked the contents of the data? Your code suggests to me that
upon reaching a none numeric (ie. 0.o value) then you jump out5 of the loop.
Perhaps you have a record prior to the end which contains data other than
what you actually expect.
Back to top
Ney André de Mello Zunino
Guest





PostPosted: Thu Jul 20, 2006 3:49 am    Post subject: Re: Last record not being processed Reply with quote

Mark Richards wrote:

Quote:
Have you checked the contents of the data? Your code suggests to me that
upon reaching a none numeric (ie. 0.o value) then you jump out5 of the loop.
Perhaps you have a record prior to the end which contains data other than
what you actually expect.

Thanks for the suggestion. I have checked the data and there is nothing
wrong with it. I was working with a tiny dataset of 5 records. They all
hold floating-point numbers in the "correlation" column.

Regards,

--
Ney André de Mello Zunino
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.