Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replace not working!! ahhhhhhh!!!!
Message
De
06/12/2000 10:58:04
Erin Eby
Mission Critical Software
Gainesville, Floride, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Replace not working!! ahhhhhhh!!!!
Divers
Thread ID:
00449956
Message ID:
00449956
Vues:
58
:) Good morning all. I have a question...I have a field in a table that is numeric, and is incremented by 1 for each record. The table is a list of items. Each item must have a unique number. I would like to run a SCAN statement to update the entire table (3000 records) with an auto-incrementing number for each record. here's my code:

LOCAL ln_cnt
ln_cnt = 100001
SELECT 0
USE tablename AGAIN ALIAS x_tablename
SELECT item, uniqnum from x_tablename order by uniqnum into cursor c_items

SELECT c_items
GO TOP

SCAN

SELECT x_tablename
LOCATE FOR ;
item = c_items.item
IF FOUND()
REPLACE x_tablename.uniqnum WITH ln_cnt
ln_cnt = ln_cnt + 1
ELSE
MESSAGEBOX("Item not found.")
ENDIF
ENDSCAN
******************************************8
when it gets done...each record should have a unique number beginning with 100001 (in theory :). however, when i go back to check my table, it has only updated the first record, and nothing else has happened. i run the entire code again, and this time it updates 2 records. i run the entire code again, and it updates another record, however, it duplicates the number. so i have 3 records updated with numbers of 100001, 100002, 100003. and the rest of the table is the same. any clues??? TIA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform