uses
...
  nxsdTableMapperDescriptor,
  nxsdDataDictionary,
  nxsdServerEngine,
  nxsdTypes,
...

var
 idxField,
 idxTable: Integer;
 NewDict, Dict: TnxDataDictionary;
 TaskInfo: TnxAbstractTaskInfo;
 Completed: Boolean;
 TableMapper: TnxTableMapperDescriptor;
 TaskStatus: TnxTaskStatus;
 NeedRestruct: Boolean;
begin
 Dict := TnxDataDictionary.Create;
 TableMapper := TnxTableMapperDescriptor.Create;
 try
   // get the old dictionary
   nxDatabase1.GetDataDictionary(TableList[idxTable], '', Dict);
         // create a new one and assign the old one
   NewDict := TnxDataDictionary.Create;
   NewDict.Assign(Dict);
   // add a new field; here you can also do other manipulations
   NewDict.fieldsdescriptor.ADDFIELD('NewFieldName','',nxtshortstring,10,0,false,nil)
   // setup the mapper
   TableMapper.MapAllTablesAndFieldsByName(Dict, NewDict);
   // and finally restructure and wait until the process is done
   nxCheck(nxDatabase1.RestructureTableEx(TableList[idxTable], '', newDict, TableMapper, TaskInfo));
   try
     if Assigned(TaskInfo) then begin
       repeat
         TaskInfo.GetStatus(Completed, TaskStatus);
         if pbRestruct.Max <> TaskStatus.tsTotalRecs then
           pbRestruct.Max := TaskStatus.tsTotalRecs;
         pbRestruct.Position := TaskStatus.tsRecsRead;
         pbRestruct.Refresh;
         if not Completed then begin
           Sleep(500)
         end;
       until Completed;
       nxCheck(TaskStatus.tsErrorCode);
     end;
   finally
     if Assigned(TaskInfo) then
       TaskInfo.Free;
   end;
 finally
   Dict.Free;
   TableMapper.Free;
 end;
end;

Home | Site Contents | Documentation | NexusDB Manual V4 | Delphi Guide | Code Examples & Fragments