You are not logged in.
Pages: 1

I need of a tool to convert a small version of my database to a new version. My old databse is similat to new database but on new database I have remove some record and remane some of them.
On my tool I use this code to set new record value from old record value:
    while TableOld.FillOne do
      begin
        TableNew := TableNameNew.Create;
        for i := 0 to Length(TableOld.RecordProps.FieldsName) - 1 do
          begin
            Excluded := False;
            for a := 0 to Length(ExcludedFields) - 1 do
              begin
                if LowerCase(TableOld.RecordProps.FieldsName[i]) = LowerCase(StringToUTF8(ExcludedFields[a])) then
                  begin
                    Excluded := True;
                    Break;
                  end;
              end;
            Modified := -1;
            for a := 0 to Length(ModifiedFieldsOld) - 1 do
              begin
                if LowerCase(TableOld.RecordProps.FieldsName[i]) = LowerCase(StringToUTF8(ModifiedFieldsOld[a])) then
                  begin
                    Modified := a;
                    Break;
                  end;
              end;
            if not Excluded then
              begin
                if Modified > -1 then
                  begin
                    TableNew.SetFieldVariant(ModifiedFieldsNew[Modified], TableOld.GetFieldVariant(TableOld.RecordProps.FieldsName[i]));
                  end
                else
                  begin
                    TableNew.SetFieldVariant(TableOld.RecordProps.FieldsName[i], TableOld.GetFieldVariant(TableOld.RecordProps.FieldsName[i]));
                  end;
              end;
          end;
        TableNew.ID := TableOld.ID;
        DatabaseDummy2.Add(TableNew, True, True);
        TableNew.Free;
      end;This code works, but I have some problem with DATE fields. All DATE fields of my new database are "30/12/1899".
Do you have any advice to copy all formats without problems?
Thanks
Offline
SetFieldVariant / GetFieldVariant is perhaps not the best way to process it.
You may simply use GetValue / SetValue, and a temp RawUTF8.
Note also that you have some dedicated methods to locate a field, without coding a loop, named FieldIndex() or FieldIndexFromRawUTF8().
Offline

I think you mean GetFieldValue/SetFieldValue. There are not GetValue/SetValue.
Do you think GetFieldValue/SetFieldValue work also with TSQLRawBlob record?
Last edited by array81 (2012-04-17 12:26:05)
Offline
I meant TPropInfo.GetValue() and TPropInfo.SetValue(), since you are working on the field level.
GetFieldValue/SetFieldValue are wrapper around those methods.
It will handle TSQLRawBlob directly.
Offline
Pages: 1