Dear CoreLab;
By using OraQuery Component, I had tried to update some records with CachedUpdates = true, after invoke ApplyUpdates, some record raise update error, how I can locate this record, I had tried OraQuery.RecNo, but it gives me the current record not the record with the updates error.
The Question is, When invoke ApplyUpdate, How to locate the record that raise the update error in case of CachedUpdates = true?
Best Regards,
Ahmed Hijazi P. Eng.
Updates Error when CachedUpdates = true
You should write OnUpdateError event hadler. Inside the hadler code you can get field values for a record where an error occurs. You can use properties of TField like Value, OldValue, NewValue.
For example, you can get a value for the primary key of record with an error:
For example, you can get a value for the primary key of record with an error:
Code: Select all
Id := OraQuery.FieldByName('ID').AsInteger;Dear CoreLab;
Thanks for fast reply, but that not what I really want.
The question is how to locate the record it self, I am using a DBGrid, and I need to highlight the record with the update error, I tried to use the RecNo property but it give me a strange number not even in the range of records count.
Note: I have found a workaround, by using the Locate function, storing the ID field of the update error record, and then pass this value to Locate function on Exception case… but it does not work all the time, some times ID field value of the new inserted records is not exist.
Best Regards,
Ahmed Hijazi, P. Eng.
Thanks for fast reply, but that not what I really want.
The question is how to locate the record it self, I am using a DBGrid, and I need to highlight the record with the update error, I tried to use the RecNo property but it give me a strange number not even in the range of records count.
Note: I have found a workaround, by using the Locate function, storing the ID field of the update error record, and then pass this value to Locate function on Exception case… but it does not work all the time, some times ID field value of the new inserted records is not exist.
Best Regards,
Ahmed Hijazi, P. Eng.
You can use the following code inside OnUpdateError event handler to get record number:
Code: Select all
RecNo := TDBAccessUtils.GetIRecordSet(OraQuery).RecordNo;