Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Determine SQL ID
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01092510
Message ID:
01092630
Vues:
24
Thanks Sergey.

Actually, SCOPE_IDENTITY pointed me to IDENT_CURRENT.

I added IDENT_CURRENT to my SQL class, where I pass in the table name:
** Form the query
sQuery = "SELECT IDENT_CURRENT('" + ALLTRIM(sTableName) + "')"

** Run the query
iResult = SQLExec(.iConnHandle, sQuery, "last_id")

** If the command completed successfully
IF iResult > -1

  ** Store the results to the return value
  iRetVal = last_id.exp
	
  ** Close the last_id table
  USE IN last_id

ELSE

  ** Call the routine to record the error info
  ._GetErrorInfo()

ENDIF
>>If I have a header and line item table, and I want to insert a record into both,
>>after the SQLEXEC command, how do I know the primary key of the header record to
>>use in the detail record?
>
>If you're refering to an IDENTITY column, check SCOPE_IDENTITY, and @@IDENTITY in BOL.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform