about fetch records

sinys

Member²
Hello.

I'm use DOA 4.1.1.0 for Delphi 7.

I have a problem.

DataSet has parameters:

Code:
QueryAllRecords = False
CountAllRecords = True

Runtime:

Code:
OracleDataSet1.Open;
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // Return 3500 rows
ChangeFilter; // in my case OracleDataSet1.Filter := '';
OracleDataSet1.Filtered := True;
OracleDataSet1.FilterOptions := [foCaseInsensitive];
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // Return 1 row
Why?

And next problem.

DataSet has parameters:

Code:
QueryAllRecords = False
CountAllRecords = False

Runtime:

Code:
OracleDataSet1.Open;
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // Always return 0 rows
How to know, how many records(0, 1 or more) after opening will be returned by the query, without query for count(*) records, because it takes a time.
 
How to know, how many records(0, 1 or more) after opening will be returned by the query, without query for count(*) records, because it takes a time.
You would need to set QueryAllRecords to True. As a result you will now the exact number of records when the dataset is opened, and no count(*) query is executed.
 
I want without query for count(*) records, because it is a long.
May need to add a property WaitFetchRecords(RecordsCount)?

QueryAllRecords = False
CountAllRecords = False

Code:
OracleDataSet1.Open;
OracleDataSet1.WaitFetchRecords(3); // wait when return 3 or more records (because I know that DOA fetch to 25 records) or last record
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // example return 1
it's possible? Do you can this?

 
Marco Kalter said:
And what with my first problem?
What exactly is the problem?
DataSet has parameters:
QueryAllRecords = False
CountAllRecords = True
Runtime:

Code:
OracleDataSet1.Open;
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // Return 3500 rows
ChangeFilter; // in my case OracleDataSet1.Filter := '';
OracleDataSet1.Filtered := True;
OracleDataSet1.FilterOptions := [foCaseInsensitive];
ShowMessage(IntToStr(OracleDataSet1.RecordCount)); // Return 1 row
[size=14pt]Why?[/size]

Marco Kalter said:
Can you elaborate?
Ok, my example:
QueryAllRecords = False
CountAllRecords = False [size=11pt]// because it is a long![/size]

Code:
procedure TMainForm.ButtonFindClick(Sender: TObject);
begin
  OracleDataSet1.SetVariable('Name', Edit1.Text);
  OracleDataSet1.Refresh;
  OracleDataSet1.WaitFetchRecords(2);
  case OracleDataSet1.RecordCount of
    0 : ShowMessage('Not found.');
    1 : EditName.Text := OracleDataSet1.FieldByName('FullName').AsString;
    else
      begin
        FormChoice.DataSource1.DataSet := OracleDataSet1;
        FormChoice.ShowModal;
      end;
  end;
end;

 
The table in the database have some millions records (The query must be for this table). There is a bad connection between server and client.

Parameters, which was set for "DataSet":
QueryAllRecords = False
CountAllRecords = False
It had done for a support of maximum speed.

After execution of query on server and after uploading of some first rows on client, I want to know, how much rows was returned by query in this moment, BEFORE then all millions of rows will be upload.

If count is 0, i want to print that there is no rows by condition. If that is 1 - i want to insert this row in TEdit. If count of rows is slightly, we must allow to do a choice for user.
If my idea was possible to realise, I added temporary nonexistent parameter, which, i think, must be wait, when the two first rows will be returned (or less, if the query will return less).
 
Setting the QueryAllRecords and CountAllRecords properties to False seems like the best (fastest) option. If you want to know whether 0, 1 or more records will be returned, you can perform a First, Next, Next and check Eof.
 
Thanks, it's work!

What with first problem? Why after set filter = '' and filtered = True RecordCount return 1 (See my first example).
 
If the filter expression is empty, then effectively there is no filter and all records will pass. The RecordCount property will reflect how many records have been fetched into the result set at that time.
 
Back
Top