In Memory DB and working indexes. lazarus / 16-Databases ---------------------------------------------------------------------- liewald · 2012-02-28 14:08 I feel I'm going round in circles and getting no where. Can anyone come up with a working suggestion. What I want to do is actually very simple. I want to create a simple in memory database that I can index to enable me to do either a quick lookup or a sql select to return one row of data that I can use to complete my task. Current state of affairs Tbufdataset and all decendants : Broken  (numerous reports in bug tracking SQLLite : I'm stuck. Can create database and store data without a problem, Locate is extremely slow and if I try a SQL statement then all data lost as need to activae select sql using "SQL.open" to get returned dataset I'm out of Ideas! HELP! ---------------------------------------------------------------------- tatamata · 2012-02-28 14:29 zmsql. indexing for sorting are being created automatically. There is SortDataSet method available. Locate works. SQL included. ---------------------------------------------------------------------- liewald · 2012-02-28 14:42 Sorry but it's suffering from the same problems being a decendant http://bugs.freepascal.org/view.php?id=19631 http://bugs.freepascal.org/view.php?id=20514 ---------------------------------------------------------------------- denver · 2012-02-28 15:56 I am using kbmMemTable version 5.6 , so far so good. ---------------------------------------------------------------------- liewald · 2012-02-28 16:01 I'm on linux unfortunately! I haven't found an installable version. Any Ideas? ---------------------------------------------------------------------- denver · 2012-02-28 16:22 It work on both linux and window. I found a bug kbmMemTable.Locate in linux and fixed with the following code : Code: [Select] interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Dialogs,Menus,   kbmMemTable, kbmMemBinaryStreamFormat,kbmMemCSVStreamFormat, db,   StdCtrls, ComCtrls, ExtCtrls, Variants ;     TMyMemTable = class( TkbmMemTable )      function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override;   published     Constructor Create(AOwner:TComponent); override;     Destructor Destroy; override;   private     function _LocateMemDataSet( FieldNames:String; aValues:String): Boolean;   public     BinaryFormat : TkbmBinaryStreamFormat ;     CSVFormat : TkbmCSVStreamFormat ;   end;     function dgStrSeg(Str ,SegSymbol: String ; SegIndex: integer): String;   function dgStrSegCount(Str,SegSymbol: String): integer; implementation function dgStrSeg(Str, SegSymbol: String; SegIndex: integer): String; var    r,c,s,sTmp : String;    i:integer; begin   r:='';   if ((Str='') or (SegIndex<1)) then      begin        result:=r;        exit;      end;   c:=UTF8ToAnsi(SegSymbol);   if (c='') then c:=',';   i:=0;   s:=UTF8ToAnsi(Str);   sTmp:='';   while Pos(c,s)>0 do         begin           i:=i+1;           sTmp := Copy(s,1,Pos(c,s)-1);           if (SegIndex=i) then              begin                r:=AnsiToUTF8(sTmp);                break;              end;           s:=Copy(s , Pos(c,s)+Length(c) , Length(s)-(Pos(c,s)+Length(c))+1);         end;   if SegIndex=(i+1) then      begin        r:=AnsiToUTF8(s);      end;   result:=r; end; function dgStrSegCount(Str, SegSymbol: String): integer; var r,i:integer;     c,s,sTmp : String; begin   r:=0;   if (Str='') then      begin        result:=r;        exit;      end;   c:=UTF8ToAnsi(SegSymbol);   if (c='') then c:=',';   i:=0;   s:=UTF8ToAnsi(Str);   sTmp:='';   while Pos(c,s)>0 do         begin           i:=i+1;           sTmp := Copy(s,1,Pos(c,s)-1);           s:=Copy(s , Pos(c,s)+Length(c) , Length(s)-(Pos(c,s)+Length(c))+1);         end;   r:=i+1;   result:=r; end;   function TMyMemTable.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; begin  {$IFDEF win32}   Result := inherited Locate(KeyFields, KeyValues, Options) ;  {$ELSE}   Result := _LocateMemDataSet( KeyFields, KeyValues ) ; {$ENDIF} end; constructor TMyMemTable.Create(AOwner: TComponent); begin   BinaryFormat := TkbmBinaryStreamFormat.Create( AOwner ) ;   CSVFormat := TkbmCSVStreamFormat.Create( AOwner ) ;   inherited Create(AOwner);   AllDataFormat := BinaryFormat ;   DefaultFormat := BinaryFormat ; end; destructor TMyMemTable.Destroy; begin  CSVFormat.Free ;  BinaryFormat.Free ;  inherited Destroy; end; function TMyMemTable._LocateMemDataSet(FieldNames: String; aValues: String ): Boolean; var   field_count:integer;   i,j:integer;   is_find:boolean; begin   is_find:=false;   First;   while not Eof do   begin     is_find:=true;     for i:=1 to dgStrSegCount(FieldNames,';') do     begin       if ( FieldByName( dgStrSeg(FieldNames,';',i)).AsString<> dgStrSeg( aValues,';',i)) then is_find:=false;     end;     if is_find then break;     Next;   end;   result:=is_find; end; and working fine for years ...... ---------------------------------------------------------------------- 99Percent · 2012-03-10 22:05 Quote from: denver on February 28, 2012, 04:56:14 pmI am using kbmMemTable version 5.6 , so far so good. Where can I find it for Linux 64?