Insert new record in QBE-Mode

wkd24154

Member²
How can I insert a record if the TOracleDataSet is in QBE mode without executing the query?
If I set the QBEMode to false the query is executed and after that a new record is insert. Here a little example:

with odsTest do
begin
if QBEMode then
QBEMode := False;

Insert;
end;
 
You could set QueryAllRecords to False to ensure that not all records are fetched, or add a "where 1 = 0" to the SQL. This will still execute the query though.
 
I can only imagine that your application either explicitly navigates to the last record, or that a data-aware component is connected to the dataset that implicitly navigates to the last record.
 
I really don't understand why setting QBE mode or ClearQBE re-execute the query instead of simple restoring the pre-QBE state of dataset, this seems absolutely illogical.
 
Originally posted by Marco Kalter:
The previous state of the dataset is restored by executing the query.
This is absolutely clear. Unclear why previous state of the dataset can't be just saved on entry to QBE mode and then restored on QBE cancel. I guess you may introduce a new field (something like RecordsWhileQbe), then do RecordsWhileQbe := Records and then create new TRecordDataList and assign it to records records. On leaving QBE you may restore what you need.

This is, definitely, very rough sketch, but I hope, that this idea can be implemented with reasonable amount of efforts.

The main problem with query re-executing is that query may be quite time-consumng.
 
Back
Top