updatemode:=upWhereChanged;

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
halenpolen
Posts: 31
Joined: Sun 27 Jun 2010 20:50

updatemode:=upWhereChanged;

Post by halenpolen » Wed 17 Nov 2010 01:09

Hi
What I should do??If I need to use this behavior updatemode:=upWhereChanged; is like in TDataSetProvider's options

I find the option Tuniquery/tunitable -> UpdateAllfields:=true

but I need update mode with where primary key + only change fields(not all)

How ??

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 17 Nov 2010 10:27

Hello,

Unfortunately such feature is not available.
We will consider the possibility of adding this feature in one of the next builds/versions.
You can manually create key fields for each update, for example, like this:

UniQuery1.sql.Text:='select ID, text, data from test';
UniQuery1.KeyFields:= 'ID';
UniQuery1.Open;;
UniQuery1.First;
UniQuery1.Edit;
UniQuery1['ID']:=8;
UniQuery1['text']:='test';
OldKeyField:= UniQuery1.KeyFields;
for i:= 0 to UniQuery1.FieldCount -1 do
begin
if (UniQuery1.Fields.FieldNameOldKeyField) and (UniQuery1.Fields.newValueUniQuery1.Fields.OldValue) then
if UniQuery1.KeyFields ='' then
UniQuery1.KeyFields:=UniQuery1.KeyFields+UniQuery1.Fields.FieldName
else
UniQuery1.KeyFields:=UniQuery1.KeyFields+';'+UniQuery1.Fields.FieldName;
end;
UniQuery1.Post;
UniQuery1.KeyFields:=OldKeyField;



in this case the update statment will be the following:

UPDATE TEST
SET
ID = :ID, TEXT = :TEXT
WHERE
ID = :Old_ID AND TEXT = :Old_TEXT

:ID(Float,IN)=8
:TEXT(String[4],IN)='test'
:Old_ID(Float,IN)=6
:Old_TEXT(String[10],IN)='11a11a1aaa'

halenpolen
Posts: 31
Joined: Sun 27 Jun 2010 20:50

Post by halenpolen » Wed 17 Nov 2010 12:49

Thanks :)

Post Reply