Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert vs Append
Message
De
06/11/1999 10:10:47
John Mcdonald
Computers and Communications Ltd.
Deer Lake, Guatemala
 
 
À
06/11/1999 09:44:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00288011
Message ID:
00288016
Vues:
18
Assuming that the table has an unique index on the Id_Nr field of the table, we usually do the following:


Sele Mytable && The table you are about to update
set orde to Unique_Index && A unique index
go bott && Get the highest number
stor Id_Nr+1 to mnewnr && Add 1 to it
INSE INTO Mytable (Id_Nr) valu(mnewnr) && Insert the new number


If the Id_Nr field is a character type, use the following:

Sele Mytable && The table you are about to update
set orde to Unique_Index && A unique index
go bott && Get the highest char number
stor STR(VAL(Id_Nr)+1,4) to mnewnr && Based on a 4 char field
INSE INTO Mytable (Id_Nr) valu(mnewnr) && Insert the new number

Keep in mind that if you use a character field for the Id or Reference number of a table, you should always start at a number like 100, 1000, 10000, etc. If you start at a blank the index will display the records incorrectly.


Hope it helps... :)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform