Topic: Cached updates problem with ADQuery
|
|
KRobert
User
 Fresh Boarder
| Posts: 6 |   | Karma: 0 |
|
Cached updates problem with ADQuery
|
|
Posted: 2007/11/21 00:32 |
|
|
|
|
Hello!
I make a mistake in the insert sql intentionally. If I switch on the cached uptates, I can't get an error message, when try to insert a record (in the grid/cache the new record is visible, but naturally in the database not). If I switch off the cached updates in the ADQuery then I get error message at insert, but the delete throw an error: "Not in cached update mode". Please help me if you can,
Robert
I use ADQuery + UpdateSql (Delphi7 + Oracle10g + AnyDac 1.12.2).
|
|
Diman
Admin
 Admin
| Posts: 1470 |  | Karma: 18 |
|
Re:Cached updates problem with ADQuery
|
|
Posted: 2007/11/21 06:27 |
|
|
|
|
Hello Robert
1) As I have described ApplyUpdates method hides exceptions. Really exception objects will be associated with row objects. 1.1) If you care about, that exception is not visible, then add OnUpdateError handler:
procedure TForm1.ADQuery1UpdateError(ASender: TDataSet;
AException: EADException; ARow: TADDatSRow;
ARequest: TADPhysUpdateRequest; var AAction: TADErrorAction);
begin
ShowMessage(AException.Message);
end;
|
1.2) If you care about, that ApplyUpdate does not raise exception, then oyu can do something like that:
if ADQuery1.ApplyUpdates > 0 then
raise Exception.Create('There were errors');
|
2) If you switch off CachedUpdates, then you cannot use ApplyUpdates method. But Post/Delete methods will use TADUpdateSQL object (in BDE that is not True). And all exceptions will be visible to the surrounding code.
Regards,
Dmitry
|
|
KRobert
User
 Fresh Boarder
| Posts: 6 |   | Karma: 0 |
|
Re:Cached updates problem with ADQuery
|
|
Posted: 2007/11/22 02:07 |
|
|
|
|
Hello!
Well, it is still not working. I have tried you advised: Query.UpdateError event, but if (found in your demo) I don't add UpdateSql.Apply(ARequest, AAction, AOptions); in the QueryUpdateRecord event, it isn't throwing error, even If I put showmessage in the updateerror event.
Is this mean that I always have to use the previous techique?
Robert
|
|
Diman
Admin
 Admin
| Posts: 1470 |  | Karma: 18 |
|
Re:Cached updates problem with ADQuery
|
|
Posted: 2007/11/22 02:18 |
|
|
|
|
Once more: 1) ApplyUpdates does not raise exception. 2) Post/Delete does raise.
Regards, Dmitry
|
|
|