For now the table has 47 fields so I am very interested if there are any shortcuts here. Else it will be a very long code to do the task
Any possible shortcuts
Any possible shortcuts
I need to take a record from a table, change the value of one field and write the data back as a new record.
For now the table has 47 fields so I am very interested if there are any shortcuts here. Else it will be a very long code to do the task
For now the table has 47 fields so I am very interested if there are any shortcuts here. Else it will be a very long code to do the task
-
AndreyZ
Re: Any possible shortcuts
You can use the code like the following:
Code: Select all
var
Values: array of variant;
i: integer;
begin
UniQuery1.SQL.Text := 'select * from tablename';
UniQuery1.Open;
SetLength(Values, UniQuery1.FieldCount);
for i := 0 to UniQuery1.FieldCount - 1 do
Values[i] := UniQuery1.Fields[i].Value;
UniQuery1.Append;
for i := 0 to UniQuery1.FieldCount - 1 do
UniQuery1.Fields[i].Value := Values[i];
UniQuery1.FieldByName('ID').AsInteger := New_PK_Value; // the new value for the Primary Key field
// other modifications
UniQuery1.Post;
end;Re: Any possible shortcuts
Looks like a plan - I will try to work with that
Thanks
Thanks
-
AndreyZ
Re: Any possible shortcuts
I am glad to help. If any other questions come up, please contact us.