|
Log in | ||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Ok, I know this should be a simple task -- but I can't seem to make this
work. Please tell me what I'm missing: Using D7, Nexus 2.05 I have a datamodule with an embedded server, an nxTable (dbClaims), and an nxMemTable (memClaims). Everything is linked correctly together (Database, Session, etc.). What I want to do is "clone" the structure of dbClaims to memClaims. Up to this point, memClaims does not have field defs or a tablename, but it is connected to the database/session. Here's the clone routine (using EM as an example): procedure TdmEmbed.cloneTableStructures; var ddNX : TnxDataDictionary; bWasOpen : Boolean; sTableName: string; begin // dbClaims first sTableName := '#tempClaims'; ddNX := TnxDataDictionary.Create; with dbClaims do try bWasOpen := Active; ddNX.Assign(_Dictionary); Database.CreateTableEx(False, sTableName, '', ddNX); finally ddNX.Free; if not bWasOpen then Close; end; with memClaims do begin TableName := sTableName; Open; // <-- problem here end; // with end; This routine is called at the end of the data module's DataModuleCreate event, after the dbClaims table has been opened. When the "Open;" line gets hit for the memClaims table -- after the tablename has been assigned -- Nexus throws a $2713/10003 error: "FieldsDescriptor requires a minimum of one field." What am I missing? I've used several different cloning and/or memory table examples I've found in the newsgroups, etc., but all have the same results. Thanks! Bj |
|
#2
|
|||
|
|||
|
Bj Marowitz wrote:
> procedure TdmEmbed.cloneTableStructures; > var > ddNX : TnxDataDictionary; > bWasOpen : Boolean; > sTableName: string; > begin > // dbClaims first > sTableName := '#tempClaims'; > ddNX := TnxDataDictionary.Create; > with dbClaims do > try > bWasOpen := Active; Active := True; > ddNX.Assign(_Dictionary); > Database.CreateTableEx(False, sTableName, '', ddNX); > finally > ddNX.Free; > if not bWasOpen then > Close; > end; > with memClaims do > begin > TableName := sTableName; > Open; // <-- problem here > end; // with > end; > > This routine is called at the end of the data module's DataModuleCreate > event, after the dbClaims table has been opened. > > When the "Open;" line gets hit for the memClaims table -- after the > tablename has been assigned -- Nexus throws a $2713/10003 error: > > "FieldsDescriptor requires a minimum of one field." > > What am I missing? I've used several different cloning and/or memory table > examples I've found in the newsgroups, etc., but all have the same results. See above... Cheers, Thorsten |
|
#3
|
|||
|
|||
|
Hi Thorsten -
Thanks for the reply, but unfortunately that doesn't correct the problem On Thu, 04 May 2006 08:24:53 +1000, Thorsten Engler [NDA] wrote: >> with dbClaims do >> try >> bWasOpen := Active; > Active := True; >> ddNX.Assign(_Dictionary); >> Database.CreateTableEx(False, sTableName, '', ddNX); >> finally >> ddNX.Free; >> if not bWasOpen then >> Close; >> end; >> with memClaims do >> begin >> TableName := sTableName; >> Open; // <-- problem here >> end; // with >> end; The dbclaims table (the source table) is already open; I added the "Active := True;" statement anyways, but still no go. Bj |
|
#4
|
|||
|
|||
|
Bj Marowitz wrote:
> Hi Thorsten - > > Thanks for the reply, but unfortunately that doesn't correct the problem > > On Thu, 04 May 2006 08:24:53 +1000, Thorsten Engler [NDA] wrote: >>> with dbClaims do >>> try >>> bWasOpen := Active; >> Active := True; >>> ddNX.Assign(_Dictionary); >>> Database.CreateTableEx(False, sTableName, '', ddNX); >>> finally >>> ddNX.Free; >>> if not bWasOpen then >>> Close; >>> end; >>> with memClaims do >>> begin >>> TableName := sTableName; >>> Open; // <-- problem here >>> end; // with >>> end; > > The dbclaims table (the source table) is already open; I added the "Active > := True;" statement anyways, but still no go. > > Bj Are you by any chance using a TnxMemTable for memClaims?? If yes, replace that with a TnxTable!! TnxMemTable automatically creates the table from it's FieldDefs / IndexDefs when you open it and deletes the table when closing. That's not what you want. You already created the mem table directly using Database.CreateTableEx and you just want to open a cursor to that table. Which is what TnxTable does. Cheers, Thorsten |
|
#5
|
|||
|
|||
|
Thorsten -
On Fri, 05 May 2006 10:28:36 +1000, Thorsten Engler [NDA] wrote: > Are you by any chance using a TnxMemTable for memClaims?? If yes, > replace that with a TnxTable!! TnxMemTable automatically creates the > table from it's FieldDefs / IndexDefs when you open it and deletes the > table when closing. That's not what you want. You already created the > mem table directly using Database.CreateTableEx and you just want to > open a cursor to that table. Which is what TnxTable does. Thank you! I had it mostly wrong (conceptually), and your comments straightened me out. I then went back and re-read your post "Re: Memory table savetofile and loadfromfile", and it all makes much more sense now. Working as expected. Thanks again! Bj |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Print table structure | Mervin Pearce [SACS] | nexusdb.public.support | 2 | 17th January 2006 06:26 AM |
| Get table structure in SQL | Alexander Telegin | nexusdb.public.support.sql | 3 | 20th December 2005 02:39 PM |
| Cannot print table structure | Zoran | nexusdb.public.support | 1 | 29th June 2005 09:02 PM |
| Print Table Structure | Malcolm Cheyne | nexusdb.public.discussions | 17 | 1st April 2005 12:05 AM |
| Printing Table Structure | Richard Wilson | nexusdb.public.support | 0 | 15th January 2004 05:15 PM |