Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending data from free table
Message
From
01/04/2000 08:54:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/04/2000 01:48:46
General information
Forum:
Visual FoxPro
Category:
Visual ProMatrix
Miscellaneous
Thread ID:
00353829
Message ID:
00353879
Views:
11
>Alex,
>
>>specialty.dbf
>> sp_id - integer - primary index generated by SRACCGPK(0)
>> specialty - 60 chars
>>
>>Now I need to append to this table all the records in another .dbf (I'm creating a vfp app that will replace an existing alpha4 thing).
>>
>>The problem is that when I do an append from spclty, the primary key doesn't get generated. The sp_id for all the newly added records remain 0.
>
>1) Does the sp_id get generated properly if you APPEND and fill in the other field manually? In other words, the ID-Generation function is working when you add a new record?
>
>2) I assume you don't have the primary key INDEX tag on the table yet, since it should not allow you to APPEND multiple records with sp_id = 0 without giving a "Uniqueness of Index ID is Violated" error.
>
>3) Does the table you are appending FROM have the same field sp_id? If so, the DEFAULT value in your new table will not fire on the APPEND FROM. Eliminate that field from the source table and the default function will fire.


David,
Sorry this is VPM specific thing, I kicked in to reply.
FYI VPM's primary implementation is different and you can have primary keys w/o a primary tag. In manual mode it would be generated correct for framework classes call SRACCGPK() primary generation routine. Also VPM's default implementation is different that users need not to set "default" in DBC and that's the problem here.
Alex, there are solution(s) to the problem :
1) Set "default" SRACCGPK(-1) in DBC also (I prefer -1 over 0) and then append.
2) Before appending store max(PKvalue) and recco(). Just append then replace all sp_id with recno()-nOldRecco+m.MaxPk :
select max(sp_id) from myTable into array aMaxPK
m.nOldReccount = reccount("myTable")
append ....
replace sp_id with recno() - m.nOldReccount + aMaxPK[1,1] ;
    for sp_id = 0
If you use SRACCGPK(0) you should go to data builder and update 0 with new last PK (that's sp_id of last appended record). If you use -1 then you don't need to do any update.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform