Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Having identity crisis!
Message
De
30/09/1999 12:40:15
 
 
À
30/09/1999 11:24:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00270941
Message ID:
00271165
Vues:
31
>Ian, Cetin, John, et al:
>
>Thanks to all of you for your help. I am still having trouble understanding why, if I have a remote view which includes the identity column of the table, when I issue a REQUERY() the idenity column value isn't directly readable from the view cursor.
>
>INSERT INTO tcParent (somecolumns) VALUES (somedatavalues)
>TABLEUPDATE(1,.T.,'tcParent')
>REQUERY('tcParent')
>
>Anytime after the tableupdate() I can suspend, browse the remote view cursor, and see the value I need. But when I do a calculate() Select max() statement it holds a value for many iterations of the loop, increments it and holds it again for some time, and so on....
>
>Given the spec I have, this identity column is the only sure relational identifier I have available.
>
>Thanks!
>Tom.
>
>>>Hi Tom ----
>>>
>>>Ian proposed @@IDENTITY, which is the optimal way of getting the latest ID, but that doesn't always work. Another way would be two open two connections to the table. Save on the first connection, then requery the table with the second connection and get the key that way.
>>>
>>
>>John,
>>
>>How would you know which was the record ou had just added on the second connection? Would you need another key made up from the other fields?
>>
>>In what circumstances does @@IDENTITY not work? - I ask as its been ages now since I was lucky enough to do anything with SQL Server!
Tom,
You can also create a stored procedure that does the insert for you and returns the value of @@IDENTITY in an output parameter. So you kill two birds with one stone.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform