Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting primary key after an insert
Message
From
08/06/2006 11:08:30
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01127217
Message ID:
01127846
Views:
32
>Aleksey,
>
>>No, Michel, I am saying that, if you want to get the value back, you can execute GETAUTOINCVALUE(0) as a procedure after Insert. If you simply want to use the value in the subsequent Insert then you can use GETAUTOINCVALUE(0) in VALUES list of the INSERT command.
>
>Is that code multiuser/multithread safe? I really don't see how getautoincvalue() can be used outside the context of a VFP stored proc. Also this function would seem to fail should the inserted table have an INSERT trigger which causes another autoinc field in another table to be consumed.
>
>Similar to have to using scope_identity() rather than @@identity in SQL server.

Hi David,

I believe VFPOLEDB is multiuser and multithread safe.

If you pass 0 to GETAUTOINCVALUE, it is similar to scope_identity(). Help is pretty clear on this: "0 Specifies that the last autoincremented field value returned is derived from the current scope (function, method, procedure)." Connection is a scope. Therefore, additional synchronization should be used if you execute INSERTs and GETAUTOINCVALUE(0) on different threads at the same time through the same connection (no difference with scope_identity() here).

Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform