Recent

Author Topic: Easy to use memory dataset  (Read 26397 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Easy to use memory dataset
« Reply #45 on: March 01, 2016, 01:04:48 pm »
send me an email. I will make a debug build for you and provide you with a separate link. The link is a release build.
Thanks but I dont have your email and also now I have my own working FPC trunk and happily compile it but it is in release mode, how can I make it for a debug mode?

Thaddy

  • Hero Member
  • *****
  • Posts: 16623
  • Kallstadt seems a good place to evict Trump to.
Re: Easy to use memory dataset
« Reply #46 on: March 01, 2016, 01:11:58 pm »
You really need a debug build for that, or recompile the code with debug information.
My email is easy to find. It is the first name of the owner at the website without the subdomain I mentioned in my previous link. Now, you are not a bot are you ;) So there you go.... O:-) And the website itself is the first name of the owner. Just repeat.
But I am sure they don't want the Trumps back...

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Easy to use memory dataset
« Reply #47 on: March 01, 2016, 01:23:03 pm »
Quote
You really need a debug build for that, or recompile the code with debug information.
Yes and I want to compile it with debug information but how?
Quote
My email is easy to find. It is the first name of the owner at the website without the subdomain I mentioned in my previous link. Now, you are not a bot are you ;) So there you go.... O:-) And the website itself is the first name of the owner. Just repeat.
OK  :D I mailed you if I wasn't wrong .

Thaddy

  • Hero Member
  • *****
  • Posts: 16623
  • Kallstadt seems a good place to evict Trump to.
Re: Easy to use memory dataset
« Reply #48 on: March 01, 2016, 03:02:01 pm »
:) Look at your email.
We can discuss.
But I am sure they don't want the Trumps back...

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Easy to use memory dataset
« Reply #49 on: March 02, 2016, 08:01:03 pm »
hi! a little correction for Null values:

Code: Pascal  [Select][+][-]
  1. Try
  2.           Dataset.Open;
  3.           Dataset.First;
  4.           While not Dataset.EOF do
  5.             begin
  6.                 Append;
  7.                 For I:=0 to L1.Count-1 do
  8.                   begin
  9.                       F1:=TField(L1[i]);
  10.                       F2:=TField(L2[I]);
  11.                       if not F2.IsNull then //HERE
  12.                       Case F1.DataType of
  13.                         ftFixedChar,
  14.                         ftString   : F1.AsString:=F2.AsString;
  15.                         ftBoolean  : F1.AsBoolean:=F2.AsBoolean;
  16.                         ftFloat    : F1.AsFloat:=F2.AsFloat;
  17.                         ftLargeInt : F1.AsInteger:=F2.AsInteger;
  18.                         ftSmallInt : F1.AsInteger:=F2.AsInteger;
  19.                         ftInteger  : F1.AsInteger:=F2.AsInteger;
  20.                         ftDate     : F1.AsDateTime:=F2.AsDateTime;
  21.                         ftTime     : F1.AsDateTime:=F2.AsDateTime;
  22.                         ftDateTime : F1.AsDateTime:=F2.AsDateTime;
  23.                         ftMemo     : F1.AsString:=F2.AsString;
  24.                         else         F1.AsString:=F2.AsString;
  25.                   end
  26.                   else
  27.                        F1.Value:=NULL; //AND HERE
  28.  
  29.               end;
  30.             Try
  31.               Post;
  32.             except
  33.               Cancel;
  34.               Raise;
  35.             end;
  36.             Dataset.Next;
  37.             end;
  38.         Finally
  39.           DataSet.GotoBookmark(OriginalPosition); //Return to original record
  40.           Dataset.EnableControls;
  41.           EnableControls;
  42.         end;
  43.  


Good call @GetMem. I wanted to do that but recompiling dpc distract me.
Thanks to you I test it and add First to it and now it seems working good enough. I just dont like its memory usage. it takes about triple of simple query that I just copy if its a problem its about TBufDataset and I will look at it.
Here the changed code :
Code: Pascal  [Select][+][-]
  1. var
  2.   I: integer;
  3.   F, F1, F2: TField;
  4.   L1, L2: TList;
  5.   N: string;
  6.   OriginalPosition: TBookMark;
  7. begin
  8.   Clear;
  9.   for I := 0 to Dataset.FieldCount - 1 do
  10.   begin
  11.     F := Dataset.Fields[I];
  12.     TFieldDef.Create(FieldDefs, F.FieldName, F.DataType, F.Size, F.Required, F.FieldNo);
  13.   end;
  14.   CreateDataset;
  15.   if CopyData then
  16.   begin
  17.     Open;
  18.     L1 := TList.Create;
  19.     try
  20.       L2 := TList.Create;
  21.       try
  22.         for I := 0 to FieldDefs.Count - 1 do
  23.         begin
  24.           N := FieldDefs[I].Name;
  25.           F1 := FieldByName(N);
  26.           F2 := DataSet.FieldByName(N);
  27.           L1.Add(F1);
  28.           L2.Add(F2);
  29.         end;
  30.         DisableControls;
  31.         Dataset.DisableControls;
  32.         OriginalPosition := Dataset.GetBookmark;
  33.         try
  34.           Dataset.Open;
  35.           Dataset.First;
  36.           while not Dataset.EOF do
  37.           begin
  38.             Append;
  39.             for I := 0 to L1.Count - 1 do
  40.             begin
  41.               F1 := TField(L1[i]);
  42.               F2 := TField(L2[I]);
  43.               case F1.DataType of
  44.                 ftFixedChar,
  45.                 ftString: F1.AsString := F2.AsString;
  46.                 ftBoolean: F1.AsBoolean := F2.AsBoolean;
  47.                 ftFloat: F1.AsFloat := F2.AsFloat;
  48.                 ftLargeInt: F1.AsInteger := F2.AsInteger;
  49.                 ftSmallInt: F1.AsInteger := F2.AsInteger;
  50.                 ftInteger: F1.AsInteger := F2.AsInteger;
  51.                 ftDate: F1.AsDateTime := F2.AsDateTime;
  52.                 ftTime: F1.AsDateTime := F2.AsDateTime;
  53.                 ftDateTime: F1.AsDateTime := F2.AsDateTime;
  54.                 else
  55.                   F1.AsString := F2.AsString;
  56.               end;
  57.             end;
  58.             try
  59.               Post;
  60.             except
  61.               Cancel;
  62.               raise;
  63.             end;
  64.             Dataset.Next;
  65.           end;
  66.         finally
  67.           DataSet.GotoBookmark(OriginalPosition); //Return to original record
  68.           Dataset.EnableControls;
  69.           EnableControls;
  70.         end;
  71.       finally
  72.         L2.Free;
  73.       end;
  74.     finally
  75.       l1.Free;
  76.     end;
  77.     First;
  78.   end;
  79. end;

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Easy to use memory dataset
« Reply #50 on: March 05, 2016, 10:53:42 pm »
Thanks @esvignolo.
Can any one help me to make a debug version of FPC to run more test on this code?
Now I can compile trunk version but just release mode, how can I compile and debug this new code?

 

TinyPortal © 2005-2018