Subject | recordcount.. |
---|---|
Author | Dennis Fantoni |
Post date | 2000-11-29T10:48:58Z |
I found my first error coming from the conversion from BDE.
I had a routine in a component (written by someone not working here anymore)
that had a procedure..
query.open
for n:=0 to query.recordcount-1 do begin
read data
end;
query.close;
This routine did not read all data in the query, bc. recordcount seems not
to return the number of records that match a query's where clause.
BDE would have returned the correct recordcout.
But... the problem is of course that my former colleque used a very bad
approach in the first place. What if someone deleted a record after you read
recordcount? you will read a deleted record, and will be relying on
transactions to help you out.
the correct way to read is
dataset.first
while not dataset.eof do begi
read data
dataset.next
end;
I suggest that ibobjects implemented recordcount to be the same as the BDE
recordcount (that is - the total number of rows that this query would fetch)
and that we might get another property that gives us the number of records
that are read into the query buffers right now. Call it clientrecordcount or
something.
still, sometimes it is nice to show to the user, the number of records that
match a certain search criteria. A query.recordcount would be "nice to
have".
I think everyone who are converting projects should do a search on
recordcount and fix the code where it is used. the code will most probably
misbehave when running ibo instead of bde..
A warning should also be added to the conversion document. (urge user to
search entire project for "recordcount" and see to that other measures are
used.
Regards
Dennis Fantoni
dennis@...
C/S Developer ( Delphi & Interbase ) at Danasoft A/S -
http://www.danasoft.dk
I had a routine in a component (written by someone not working here anymore)
that had a procedure..
query.open
for n:=0 to query.recordcount-1 do begin
read data
end;
query.close;
This routine did not read all data in the query, bc. recordcount seems not
to return the number of records that match a query's where clause.
BDE would have returned the correct recordcout.
But... the problem is of course that my former colleque used a very bad
approach in the first place. What if someone deleted a record after you read
recordcount? you will read a deleted record, and will be relying on
transactions to help you out.
the correct way to read is
dataset.first
while not dataset.eof do begi
read data
dataset.next
end;
I suggest that ibobjects implemented recordcount to be the same as the BDE
recordcount (that is - the total number of rows that this query would fetch)
and that we might get another property that gives us the number of records
that are read into the query buffers right now. Call it clientrecordcount or
something.
still, sometimes it is nice to show to the user, the number of records that
match a certain search criteria. A query.recordcount would be "nice to
have".
I think everyone who are converting projects should do a search on
recordcount and fix the code where it is used. the code will most probably
misbehave when running ibo instead of bde..
A warning should also be added to the conversion document. (urge user to
search entire project for "recordcount" and see to that other measures are
used.
Regards
Dennis Fantoni
dennis@...
C/S Developer ( Delphi & Interbase ) at Danasoft A/S -
http://www.danasoft.dk