Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Autoincrement field - how to implement with views?
Message
From
16/10/2003 15:39:36
 
 
To
16/10/2003 14:34:07
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00839435
Message ID:
00839474
Views:
18
>I really like that VFP finally has an auto-increment type built-in. So I'm now trying to utilize it and I'm having the similar type of issue I had with MS SQL.
>
>In a view I append a blank record but the new key hasn't been generated yet. So I can't tie in the child records. Even if I do a table update it doesn't move the keys in.
>
>I know several workarounds... But I just wanted to find out what the 'preferred' way was to handle that situation. Is there a VFP function like there is in MS SQL that you can use to find the key value that was generated?
>
>It would also be nice to have a methodology that would be easy to up-size to SQL Server later.
>
>Thanks in advance!
>
>Greg

Greg, when you use a local view, the underlying table is always open, so after the tableupdate you can get the key value from it...
USE mytableview
APPE BLANK
tableupdate()
REPLACE pk WITH mytable.pk
For SQL you can do the same thing. I assume you have a data class of some type that does your tablupdate. It can check what type of view it is and do the appropriate code to get the assigned id.

OF course, I am not on the VFP team, but I don't see any other way to do this.

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform