CachedUpdates have stopped working after moving to ODAC
Posted: Sat 07 Jun 2008 17:18
I am using Delphi 5 w/ ODAC NET v5.70.0.28. I am moving an application off BDE.
These are the steps I have followed:
TOraSession replaced TDatabase
TQuery -> TOraQuery
TUpdateSQL -> TOraUpdateSQL
For the most part, the migration has been a success. All data access components work fine. But, the updateSQL based cachedUpdates mechanism doesn't work anymore!
The query object has following properties set:
cachedUpdates := TRUE, and
updateObject := updateSQLAQuery
Please note that in order to minimize our migration efforts, we kept updateSQL objects around (only changed their declaration from TUpdateSQL to TOraUpdateSQL). Also, we did not put anything in the SQLUpdate, SQLInsert, and SQLDelete properties of the TOraQuery object. By the way, DeleteSQL, InsertSQL, and ModifySQL properties of TOraUpdateSQL object do have SQL text in them (carried over from the old TUpdateSQL objects).
Following code is attached to AfterPost event of the Query object.
procedure AQueryAfterPost(DataSet: TDataSet):
begin
if TOraDataSet(DataSet).updatesPending then
updateSQLAQuery.apply(ukModify);
end;
This code used to run fine under BDE. But under ODAC, I get the following exception and database is not updated either. Project app.exe raised exception class EDatabaseError with message 'Update failed. Found 0 records.'. I stepped through the code and the "updateSQLAQuery.apply(ukModify);" line is executed (which then raised above mentioned exception). It means that "TOraDataSet(DataSet).updatesPending" is returning TRUE, which means that it is correctly detecting the presence of unapplied changes. The next statement (i.e. apply), however, fails with "Found 0 records" exception...
By the way, if updateSQL objects are not properly supported under ODAC, and there is another better way to handle cachedUpdates under ODAC, I'll be interested in hearing about that too.
Please help! Thanks.
These are the steps I have followed:
TOraSession replaced TDatabase
TQuery -> TOraQuery
TUpdateSQL -> TOraUpdateSQL
For the most part, the migration has been a success. All data access components work fine. But, the updateSQL based cachedUpdates mechanism doesn't work anymore!
The query object has following properties set:
cachedUpdates := TRUE, and
updateObject := updateSQLAQuery
Please note that in order to minimize our migration efforts, we kept updateSQL objects around (only changed their declaration from TUpdateSQL to TOraUpdateSQL). Also, we did not put anything in the SQLUpdate, SQLInsert, and SQLDelete properties of the TOraQuery object. By the way, DeleteSQL, InsertSQL, and ModifySQL properties of TOraUpdateSQL object do have SQL text in them (carried over from the old TUpdateSQL objects).
Following code is attached to AfterPost event of the Query object.
procedure AQueryAfterPost(DataSet: TDataSet):
begin
if TOraDataSet(DataSet).updatesPending then
updateSQLAQuery.apply(ukModify);
end;
This code used to run fine under BDE. But under ODAC, I get the following exception and database is not updated either. Project app.exe raised exception class EDatabaseError with message 'Update failed. Found 0 records.'. I stepped through the code and the "updateSQLAQuery.apply(ukModify);" line is executed (which then raised above mentioned exception). It means that "TOraDataSet(DataSet).updatesPending" is returning TRUE, which means that it is correctly detecting the presence of unapplied changes. The next statement (i.e. apply), however, fails with "Found 0 records" exception...
By the way, if updateSQL objects are not properly supported under ODAC, and there is another better way to handle cachedUpdates under ODAC, I'll be interested in hearing about that too.
Please help! Thanks.