Updates Error when CachedUpdates = true

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ahijazi
Posts: 47
Joined: Mon 01 Oct 2007 11:13

Updates Error when CachedUpdates = true

Post by ahijazi » Sat 10 May 2008 07:48

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.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 12 May 2008 07:52

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:

Code: Select all

  Id := OraQuery.FieldByName('ID').AsInteger;

ahijazi
Posts: 47
Joined: Mon 01 Oct 2007 11:13

Post by ahijazi » Mon 12 May 2008 10:37

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.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 13 May 2008 08:23

You can use the following code inside OnUpdateError event handler to get record number:

Code: Select all

  RecNo := TDBAccessUtils.GetIRecordSet(OraQuery).RecordNo;

ahijazi
Posts: 47
Joined: Mon 01 Oct 2007 11:13

Post by ahijazi » Tue 13 May 2008 10:54

Thanks much, it work like I need... thanks Plash.

Post Reply