Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto-Increment Dilemma
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01099725
Message ID:
01099870
Vues:
18
No, no, you're missing missing my point.

My question was; Assuming all fields on a record are optional, and the Id is auto-incremented,
then what is left to INSERT in the SQL command?

I'm trying to create a generic AddRecord method that gets called whenever the user clicks
the Add Record button, but that adds another twist; in a generic method, you won't know what
data to insert to create a new record.

I used to use:
nNewId = GetNewPrimaryKey()
INSERT INTO MyTable (Id) VALUES (nNewId)
But now since the Id is auto-incremented, there is really no way to use a SQL INSERT
command.







>Don't include the AutoInc field in the insert statement. It's handled automatically.
>
>>Insert what?
>>
>>
>>>APPEND BLANK or SQL INSERT command. The record pointer will be sitting on the newly inserted record.
>>>
>>>>My tables all have auto-increment turned on.
>>>>
>>>>When the user clicks the New Record button on the screen, normally I
>>>>would do
>>>>
>>>>
>>>>nNewId = GetNewPrimaryKey()
>>>>INSERT INTO MyTable (Id) VALUES (nNewId)
>>>>
>>>>
>>>>All other fields on the record are data entry fields and could be optional.
>>>>
>>>>So what do you insert to add a new record when using auto-increment?
>>>>
>>>>And, how do you know what the Id was that was auto-added?
>>>>
>>>>Thanks
>>>>
>>>>Kevin
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