Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NextID for SQL syntax
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00506014
Message ID:
00506058
Vues:
17
Any reason you're not using the internal GUID assigned by SQL Server to each new record?

>What is the correct way (record locking,etc.) to make a "NextID" function for sql? I am using the following, but can forsee problems if tons of users bang on this thing at the same time:
>
>function NextID(pTable)
>select lastval from dbsequences into array laNum where tablename = pTable
>laNum[1] = laNum[1] + 1
>update dbsequences set lastval = laNum[1] where tablename = pTable
>RETURN(lnNum[1])
>
>This type of thing works fine for few users. My question is what happens when two users hit this thing at about the same time? Both will get the same number and that will cause a big problem. Somehow the record should be locked,updated,unlocked to prevent this. I know how to do it using normal VFP commands: locate for..., lock(), replace ,unlock(). etc., etc. I just can't figure out how it's done in the SQL world.
>
>- Gary
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform