Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scope_identity() not working inside VFP transaction
Message
 
À
17/06/2011 18:17:20
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01515025
Message ID:
01515029
Vues:
53
Charles, I think is better to grab the PK in the same command as the insert with the OUTPUT clause of the insert. Something like
text to lcSQL textmerge noshow flags 1 pretext 1 + 2 + 4
	INSERT INTO yourTable
		(	
			yourFieldList
		)
	OUTPUT Inserted.yourPrimaryKey
	VALUES
		(
			yourValuesList
		)
endtext
llSuccess	= Sqlexec(lnConnection, lcSQL, 'c_pk') = 1
lnNewPK		= Iif(not llSuccess or Eof('c_pk') or c_pk.pk = 0, null, c_pk.pk) && Assuming PK is your primary key field name
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform