Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 7 of 7 total |
Temporary table names? |
Sun, Mar 4 2007 1:59 AM | Permanent Link |
Sam Davis | Is there a way to create a table whose name is visible only to the
current application? I need to create temporary table that won't interfere with another instance of the program that is running. TIA Sam |
Sun, Mar 4 2007 4:55 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Sam
Two approaches: 1 The simple and easy way - Just give it a unique name. I usually use a prefix plus IntToStr(GetTickCount) on the basis I have little that's going to create two tables within a millisecond of each other. You could also use a GUID. 2. Also simple. Use a memory table. These are only visible to the process (and threads) that created them so a second instance of the app wouldn't see it. Roy Lambert |
Sun, Mar 4 2007 2:30 PM | Permanent Link |
Sam Davis | Roy Lambert wrote:
> Sam > > Two approaches: > > 1 The simple and easy way - Just give it a unique name. I usually use a prefix plus IntToStr(GetTickCount) on the basis I have little that's going to create two tables within a millisecond of each other. You could also use a GUID. I hadn't thought of using GetTickCount, but of course if there are a dozen computers doing the same thing in the same database, their gettickcount's could theoretically generate a duplicate name (if they are booted at approx the same time and create lots of these tables). I know it's splitting hairs and the chance of duplicate names is remote, but I'll have to guarantee that the table doesn't exist before I create it. Then I have to ensure the table that I think I created, does indeed belong to me and not some other application that generated at exactly the same instant. So I'll have to check for an exception during the temporary table creation. This is the type of thing I was hoping to avoid. > > 2. Also simple. Use a memory table. These are only visible to the process (and threads) that created them so a second instance of the app wouldn't see it. Yes, that's a more likely alternative. But is it not possible to create a memory table that can be shared between 2 or more computers? Or are memory tables always local to the process? Or can a shared memory table only be created on the C/S version? TIA Sam |
Mon, Mar 5 2007 3:00 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Sam
With C/S all memory tables are created on the server, but they're all limited to the process that created them (or something like that - I use fileserver). Another thought just occurred to me - you could create a slew of temp directories under the data directory. One for each user and then dump all the private stuff in those. Roy Lambert |
Mon, Mar 5 2007 7:51 AM | Permanent Link |
"Robert" | "Sam Davis" <sammyd432@yahoo.com> wrote in message news:5C2631B3-A334-4C92-9DDF-D852875B4D1B@news.elevatesoft.com... > Roy Lambert wrote: >> Sam >> >> Two approaches: >> >> 1 The simple and easy way - Just give it a unique name. I usually use a >> prefix plus IntToStr(GetTickCount) on the basis I have little that's >> going to create two tables within a millisecond of each other. You could >> also use a GUID. > > I hadn't thought of using GetTickCount, but of course if there are a dozen > computers doing the same thing in the same database, their gettickcount's > could theoretically generate a duplicate name (if they are booted at > approx the same time and create lots of these tables). I know it's > splitting hairs and the chance of duplicate names is remote, but I'll have > to guarantee that the table doesn't exist before I create it. Then I have > to ensure the table that I think I created, does indeed belong to me and > not some other application that generated at exactly the same instant. So > I'll have to check for an exception during the temporary table creation. > This is the type of thing I was hoping to avoid. > Just try an "exists" on the table, if true, get another tick count and try again. procedure TForm1.Button1Click(Sender: TObject); procedure CreateTable(var t : tDBISAMtable; Owner : pointer = nil); var l : longint; begin t := tDBISAMTable.Create(owner); // set session and database t.DatabaseName := ExtractFilePath(paramstr(0)); repeat l := GetTickCount; t.TableName := 'Temp' + IntToStr(l); until not t.Exists; end; var t : tdbisamtable; begin createtable(t); showmessage('Table created ' + t.TableName); end; >> >> 2. Also simple. Use a memory table. These are only visible to the process >> (and threads) that created them so a second instance of the app wouldn't >> see it. > > Yes, that's a more likely alternative. But is it not possible to create a > memory table that can be shared between 2 or more computers? No. Memory tables (file sharing or c/s) are local to the session. Robert |
Mon, Mar 5 2007 9:45 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Robert,
<< No. Memory tables (file sharing or c/s) are local to the session. >> Slight correction - they are confined to the process that created them, not just the session. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Mar 5 2007 9:47 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Sam,
<< Is there a way to create a table whose name is visible only to the current application? I need to create temporary table that won't interfere with another instance of the program that is running. >> As long as the table isn't huge, you can simply use an in-memory table. They are visible to only the current process. ElevateDB also allows for temporary tables whose names are local to the current process without requiring special naming. They can also be named the same as an already-defined table in order to "hide" the existing table while performing processing on the temporary table. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Sunday, May 19, 2024 at 08:46 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |