Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Access problem on memory tables
Wed, Apr 18 2007 3:33 AMPermanent Link

durumdara
Hi!

Version : 3.24.

I want to understand something that working wrong (or I do wrong).
Many times I used memory tables. Before DBISAM I used kbmMemTable. These tables don't have tablename property.
Later I replaced them with DBISAM tables.

We need to use hungarian sort order. So when I want to create a memory table, I need to restructure later, because before I create it, I cannot
change the it's language.

I use this proc. to create tables:

procedure CreateAndOpenTempMemoryDS(DS: TDBISAMTable);
var
 i : integer;
 fmt : string;
 qry : TDBISAMQuery;
begin
 if DS.Active then Exit;
 while True do begin
   fmt := 'DMT' + FormatDateTime('YYMMDD_HHMMSSZZZ', Now);
   fmt := fmt + IntToStr(Random(1000) + 1000);
   DS.Close;
   DS.DatabaseName := DBISAMMemoryDB.DatabaseName;
   DS.SessionName  := DBISAMMemorySession.SessionName;
   DS.TableName := fmt;
   if not DS.Exists then begin
     DS.CreateTable;
     DS.Close;
     qry := TDBISAMQuery.Create(nil); // The beginning of the new section
     try
       qry.DatabaseName := DBISAMMemoryDB.DatabaseName;
       qry.SessionName := DBISAMMemorySession.SessionName;
       qry.SQL.Text := 'alter table ' + DS.TableName +
         #13' LANGUAGE "Hungarian"';
       qry.ExecSQL;
     finally
       qry.Free; // End of new section
     end;
     DS.Open;
     Exit;
   end;
 end;
end;

The DBISAMMemoryDB, DBISAMMemorySession are components. They are set to memory working.

I created a new section in procedure to set the hungarian order.
But this procedure isn't working, because it is not found the table!!!
Why???

When I changed this routine to:
procedure CreateAndOpenTempDS(DS : TDBISAMTable);
var
 i : integer;
 fmt : string;
 qry : TDBISAMQuery;
begin
 if DS.Active then Exit;
 while True do begin
   fmt := 'DMT' + FormatDateTime('YYMMDD_HHMMSSZZZ', Now);
   fmt := fmt + IntToStr(Random(1000) + 1000);
   DS.Close;
   DS.DatabaseName := DBISAMLocalDB.DatabaseName;
   DS.SessionName  := DBISAMLocalSession.SessionName;
   DS.TableName := fmt;
   if not DS.Exists then begin
     DS.CreateTable;
     DS.Close;
     qry := TDBISAMQuery.Create(nil);
     try
       qry.DatabaseName := DBISAMLocalDB.DatabaseName;
       qry.SessionName := DBISAMLocalDB.SessionName;
       qry.SQL.Text := 'alter table ' + DS.TableName +
         #13' LANGUAGE "Hungarian"';
       qry.ExecSQL;
     finally
       qry.Free;
     end;
     DS.Open;
     Exit;
   end;
 end;
end;

... then it is working!
DBISAMLocalDB, DBISAMLocalSession are components, and they are set to local working (to temp dir).

But I don't understand it: why memory tables not found by the engine?

I remember that I got these errors in another projects too, and in these project I also need to replace MEMORY mode to LOCAL (TEMPDIR) mode...

Please help me a little.

Is there any differents between memory tables and local temp tables?

Because they (memory tables) are should working in these modes:
1.)
Inmemory datas (the main puffer is working in memory), but they are flushed into files when main puffer is overloaded.
2.)
Normal local tables but they are handled by the engine (released, and deleted on session destroy).
So no any differents between local tables and memory tables, only the releasing (deleting).

Please help me!

Thanks for it:
dd
Wed, Apr 18 2007 4:22 AMPermanent Link

durumdara
Hi!

Ok, I found a solution as:

       qry.DatabaseName := DBISAMMemoryDB.DatabaseName;
       qry.SessionName := DBISAMMemorySession.SessionName;
       qry.SQL.Text := 'alter table ' +
         ' MEMORY ' +
         DS.TableName +
         #13' LANGUAGE "Hungarian"';

But I don't understand, if I used "MEMORY" database with a Query, why I need to preset the SQL tablename with "MEMORY" statement?
Why DBISAM does not recognize that I also use MEMORY database, and if I don't use any prefix, it need to use MEMORY TABLES?

Thanks:
dd
Wed, Apr 18 2007 5:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Durumdara,

<< But I don't understand, if I used "MEMORY" database with a Query, why I
need to preset the SQL tablename with "MEMORY" statement? Why DBISAM does
not recognize that I also use MEMORY database, and if I don't use any
prefix, it need to use MEMORY TABLES? >>

That's just the way 3.x works.  It requires that in-memory tables be
prefixed with the MEMORY keyword in SQL.  Version 4.x is more consistent in
that it uses the "Memory" database everywhere instead.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Apr 19 2007 2:33 AMPermanent Link

durumdara
Please help me a little.

Is there any differents between memory tables and local temp tables?

How the memory tables working?

1.)
Inmemory data (the main puffer is working in memory), but the records are flushed into files when main puffer is out of it's area?

2.)
Normal local tables but they are handled by the engine (released, and deleted on session destroy)?
So no any differents between local tables and memory tables, only the releasing (deleting).


Please help me!

Thanks for it:
dd




Thu, Apr 19 2007 6:17 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

durumdara,

<< Is there any differents between memory tables and local temp tables? >>

Apart from how they are stored, no.  Each virtual file that makes up an
in-memory tables is stored in a series of in-memory blocks in an internal
virtual file system.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image