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 ??
updatemode:=upWhereChanged;
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'
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'