Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key code in sqlserver
Message
De
30/06/2007 09:39:09
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Primary key code in sqlserver
Divers
Thread ID:
01236985
Message ID:
01236985
Vues:
53
here is the code that creat PK in my vfp program.
i want to rewrite in sqlserver code. please help me.
i use a meta table called NUMERO that have all tables name.


Function numero(tcalias,xlibb)
Local lcalias, ;
lnid, ;
lcoldreprocess, ;
lnoldarea
SET EXACT on

lnoldarea = Select()

If Parameters() < 1
lcalias = Upper(Alias())
Else
lcalias = Upper(tcalias)
Endif

lcoldreprocess = Set('REPROCESS')
*-- Lock until user presses Esc
Set Reprocess To Automatic

If !Used("numero")
Use numero In 0
Endif

Select numero
Locate For UPPER(Alltr(lcalias))==UPPER(Alltr(Table))
If !Empty(lcalias)
If !Found()
Append Blank
Replace Table With Upper(lcalias)
Replace numero With 1
Endif
Else
Return
Endif
* IF SEEK(lcAlias, "numero", "table")
If Rlock() &&& or reccount(lcAlias)=0
lnid = numero.numero
Replace numero.numero With numero.numero + 1
if empty(libelle) AND !EMPTY(xlibb)
replace libelle with UPPER(xlibb)
endif
Unlock
Endif

Select (lnoldarea)
Set Reprocess To lcoldreprocess

Return lnid
ENDFUNC
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform