Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP RLock() in T-SQL ?
Message
De
18/05/2005 10:43:08
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01015009
Message ID:
01015370
Vues:
17
>I've got the follow UDF to get the next invoice number in a VFP table called DocsNumbers.
>
>LOCAL lnNext
>
>SET MULTILOCKS ON
>SET REPROCESS TO 0 Automatic
>
>SELECT DocsNumbers
>WAIT WINDOW "Gettign document number..." NOWAIT
>RLOCK()
>lnNext = DocsNumbers.invoice +1
>REPLACE DocsNumbers.invoice WITH lnNext
>TABLEUPDATE(.T.)
>UNLOCK IN DocsNumbers
>WAIT CLEAR
>
>RETURN lnNext
>
>
>How can I do this in T-SQL using a SQL server database ?
>
>T.I.A.

SQL Server performs table, page, and row-level locking automatically:
declare @Next int

begin transaction
    select @Next = invoice + 1 from DocsNumbers
    update DocsNumbers
        set invoice = @Next
end transaction
For more info about SQL locking, see "SET TRANSACTION ISOLATION LEVEL" in the BOL.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform