Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a new order on two PCs
Message
De
15/07/2016 02:48:53
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01638327
Message ID:
01638426
Vues:
74
>Based on the input from Thomas Ganss I am checking the code on my Cursor Adapter. And I find that the PK value set in the Cursor Adapter is based on the following code:
>
>
>this.ca_object.InsertCmdRefreshFieldList = ALLTRIM(tcIdentityField)
>this.ca_object.InsertCmdRefreshCmd = "SELECT @@IDENTITY"
>
>
>I thought that @@IDENTITY will get the last identity on the "current session". Therefore, I thought that it should not get the value of new identity created by another user (that is, another session). Am I wrong?
>
>UPDATE. This customer who is giving me the problem (or the other way around), I think, is using Terminal Server or some similar technology. So I am thinking that - maybe - all users, as far as SQL Server is concerned, are using the same session. Another thing to explore.

One instance where @@IDENTITY will not give you the value you want - if you have a trigger on the table and the trigger does an insert into a table that has an identity.

For a single insert....if you want the identity value directly as a result of that specific insert, use SCOPE_IDENTITY()

Also...Naomi's suggestion about INSERT INTO...OUTPUT is a good one, especially if that INSERT is inserting multiple rows. The OUTPUT piece allows you to get at the specific value(s) as a result of the INSERT. It's like getting an "echo" of what the insert eventually did. It's a great feature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform