Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Auto Increment not working with APPEND FROM
Message
From
16/04/2003 16:45:15
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00778519
Message ID:
00778613
Views:
28
>>Hello,
>>
>>I'm working with the released VFP8 and notice that AutoInc fields do not receive values if I append from another file - they get zeros. For example, if I create a simple table with an AutoInc, FName, LName, and append from a text file with first/last name, the autoinc field stays 0.
>>
>>Here is a simple example:
>>
>>1) Create the table (rename if this collides with another table)
>>2) Append blank (autoinc populates)
>>3) Create the simple text file (cut/paste from this message)
>>4) Append this small list of names with a FIELDS list excluding autoinc
>>5) Autoinc fields are zeroed
>>
>>Any ideas? Thanks,
>>
>>Franz Nisswandt
>>
>>----------------------
>>CREATE TABLE 'AUTOTEST.DBF' ( ;
>> AUTOTESTID I NOT NULL AUTOINC NEXTVALUE 3 STEP 1, ;
>> FNAME C(15) NULL, ;
>> LNAME C(25) NULL)
>>
>>APPEND BLANK && AUTOINC GETS POPULATED
>>REPLACE LNAME WITH 'SMITH', FNAME WITH 'JOHN'
>>
>>* AUTOINC FIELD IS POPULATED IF APPEND BLANK or APPEND
>>*
>>*
>>* Now, create a text file called AUTOTEST.TXT
>>* with some names:
>>
>>"JOHN","SMITH"
>>"JOE","SMITH"
>>"JILL","SMITH"
>>"JENNY","SMITH"
>>"JIM","SMITH"
>>"JAMES","SMITH"
>>"JON","SMITH"
>>
>>* Now try to APPEND these names as follows:
>>
>>APPEND FROM AUTOTEST DELI FIELDS FNAME,LNAME
>>
>>* Note how the AutoInc fields are ZEROs
>
>I think you may be stuck here. You've only specified that the fields to be added are FNAME and LNAME, so the AUTOINC field has no value. It's probably a bug, but you may be able to work around it by putting your records into a cursor first, and then appending from the cursor.

A temp 'table' works if I create the structure without the autoinc column, append from the text file that doesn't contain the autoinc column, and then append to the 'actual' table from the 'temp' table.

Append from the 'cursor' doesn't work directly - the append command doesn't seem to support the alias matching the cursor name. If I hack and use the temporary filename of the cursor, ie.,

APPEND FROM C:\DOCUME~1\FLN\LOCALS~1\TEMP\I7X002YW.TMP

then it will append. I don't like the latter solution (hack), and I also don't like the former, either - if the destination table is in a DBC with long field names, then I need to create the temp table in a DBC so I can have the long field names match for the append command.

- FLN
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform