Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Am I misusing TableUpdate()?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00261437
Message ID:
00265076
Views:
63
>>He opens the view empty, and inserts records into it from an array. But these records are really representatives of records that already exist in the base tables, so when he does a TABLEUPDATE, he just wants to use the contents of the view to update existing records instead of insert new ones. VFP, seeing that the records in the view were inserted into the view as opposed to populated by a REQUERY(), naturally performs an INSERT SQL when the TABLEUPDATE command is given, and the result is a uniqueness error, because it is trying to add a record that already exists.
>>
>>Since VFP uses the fieldstate of the contents of the view to decide how to perform the update (INSERT vs UPDATE) I have advised him to try to trick VFP using the SETFLDSTATE function to change the "new" status of the records in the view to "current", so VFP will UPDATE the base tables instead of INSERTing into them. The current state of this is an error message stemming from code that I gave him that I can't put a finger on: the code works fine for me. Any ideas along this train of thought?


Thanks Erik, you hit it right on the head whatI was trying to do.



>I don't think he will succeed. No matter what getfldstate says the record number in the view is still negative telling VFP that it is a new record. The solution, IMHO, is to use a vierw that fetches the records with SQL and then edit them and update.


That kind of stinks. Maybe I will get somewhere by scanning through my view and performing a sql-update on matching records? Of course, the ones that did not match (meaning they are truly new records) I would have to sql-insert afterwards...

Or is there some kind of way to make the record number non-negative so I can update the table properly?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform