Problem with UniDac, CachedUpdates, MS-SQL

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
itsds
Posts: 37
Joined: Mon 30 Apr 2007 10:38
Location: Germany - Bochum
Contact:

Problem with UniDac, CachedUpdates, MS-SQL

Post by itsds » Mon 31 Jan 2011 13:13

Hi i use the following method to update a table


mdQuery : TUniQuery with cachedupdates := true
SQL: select * from table

In a Procedure I do the following:

with mdQuery do begin
StartTransaction;
"ExcuteSQL"('update table set field1 = 'test' where id = 8')

mdQuery.Edit; << ERROR "Record was changed by another user" only with MS-SQL, Oracle and MySQL works fine
mdQuery.FieldByName('field1').AsString := 'test';
mdQuery.Post;

Commit;
end;


I use this Method with cachedupdates to avoid to refresh from Table cause i only change 1 Field in 100.000 Records.

at the end of all modifikations i usually call mdQuery.CancelUpdates.

itsds
Posts: 37
Joined: Mon 30 Apr 2007 10:38
Location: Germany - Bochum
Contact:

Post by itsds » Mon 31 Jan 2011 13:57

I found the Reason on this.

With OLEDBProvider set to prSQL (i use this) You create a savepoint in MS-SQL.

I modified the Code now Savepoints are disabled for prSQL also.
-> No Error anymore

I made try mdQuery.CancelUpdates except end;

to avoid the Exception at the end which is generated caus you rollback an not existing Transaction.

Please think about using TUniQuery as a cached Container which is read only to the Database for Speed - Reasons !

best regards

itsds
Posts: 37
Joined: Mon 30 Apr 2007 10:38
Location: Germany - Bochum
Contact:

Post by itsds » Mon 31 Jan 2011 14:28

Finally fixed:

I set

OldCachedUpdateLockMode: boolean = True; // Old behavior LockMode for the CachedUpdate mode

in dbaccess.pas

and all works fine now :)

AndreyZ

Post by AndreyZ » Tue 01 Feb 2011 12:22

Hello,

It's good to see that you found a solution. If any other questions come up, please contact us.

Post Reply