Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP with SQL Server -- Pkey
Message
De
16/01/2001 14:25:32
 
 
À
16/01/2001 14:09:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00464309
Message ID:
00464331
Vues:
24
>Okay. Here it is:
>
>* get the handle and get the @@identity number
> lnSQLHandle = cursorgetprop('ConnectHandle', (lctable))
> * requery the table with the identity parameter for this record
> lnUpdated = sqlexe(lnSQLHandle, 'Select @@Identity', 'sqlresult')
> If lnUpdated <= 0
> msg = "Identity value was not found -- call a programmer now"
> messagebox(msg, 0+16+0, "Identity Value Failure")
> aerror(aSqlError)
> list memory like aSqlError noconsole to print
> else
> oVar.PrimaryKey = sqlresult.exp
> select (lctable)
> lnUpdated = requery()
> If lnUpdated <=0
> msg = "Verification Requery Failed -- call a programmer now"
> messagebox(msg, 0+16+0, "Validation Requery Error")
> aerror(aSqlError)
> list memory like aSqlError noconsole to print
> else
> endif
> endif

PMFJI but, you need to be careful when reading the PK in a separate call from the insert statement. @@IDENTITY returns the last inserted identity value. If several users are inserting records at the same time or several records are being added you may not get the right PK value.

I know this doesn't answer your question but just wanted to point this out. I do not use RV's myself.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform