Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting primary key after an insert
Message
De
08/06/2006 11:08:30
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01127217
Message ID:
01127846
Vues:
36
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform