The following Delphi function can be used to add a fkInternalCalc to a TClientDataset. This is useful because I can store some information for each record, make calculation or store temporary flag.
The same code does not work in Lazarus, it stops on DataSet.FieldDefs.Update.
Are there means to achieve the same functionality? Remember that one could change database fields and apply the changes made.
A working Delphi code using the function is:
AddDummyField(qry,TIntegerField,'PROCESS_ACTION');
qry.Open;
...
function AddDummyField(Dataset:TDataset;fieldClass:TFieldClass;fieldName:string;size:integer):TField;
var
i: Integer;
begin
if Dataset.FieldDefs.Count = 0 then
begin
DataSet.FieldDefs.Update;
for i := 0 to DataSet.FieldDefs.Count - 1 do
DataSet.FieldDefs[i].CreateField(DataSet);
end;
Result := Dataset.FindField(fieldName);
if Result <> nil then
exit;
Result := fieldClass.Create(Dataset);
Result.FieldName := fieldName;
Result.FieldKind := fkInternalCalc;
Result.DataSet := Dataset;
if size>0 then
Result.Size := size;
end;