Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace not working!! ahhhhhhh!!!!
Message
 
To
06/12/2000 10:58:04
Erin Eby
Mission Critical Software
Gainesville, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00449956
Message ID:
00449987
Views:
7
Erin,

There are many ways to skin a cat, but I don't understand why you're choosing to make this process so complex. What about the following:
LOCAL ln_cnt
ln_cnt = 100000
SELE 0
USE tablename AGAIN ALIAS x_tablename
IF FLOCK()  &&  just in case others are using the table
  REPL uniqnum WITH RECNO()+ln_cnt ALL
ENDIF
HTH

Also note.. in your code... I think the REPLACE line should read..
REPLACE uniqnum WITH ln_cnt IN x_tablename

Matt

>:) 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
I try to stay online, to get better information.
I try to get away from the office once in a while..
But they KEEP... PULLING.. ME.. BACK.. IN!!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform