Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace not working!! ahhhhhhh!!!!
Message
From
06/12/2000 10:58:04
Erin Eby
Mission Critical Software
Gainesville, Florida, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Replace not working!! ahhhhhhh!!!!
Miscellaneous
Thread ID:
00449956
Message ID:
00449956
Views:
61
:) 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
Next
Reply
Map
View

Click here to load this message in the networking platform